3 * @brief This file contains the handling of command.
5 * Copyright (C) 2008-2009, Marvell International Ltd.
7 * This software file (the "File") is distributed by Marvell International
8 * Ltd. under the terms of the GNU General Public License Version 2, June 1991
9 * (the "License"). You may use, redistribute and/or modify this File in
10 * accordance with the terms and conditions of the License, a copy of which
11 * is available along with the File in the gpl.txt file or by writing to
12 * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
13 * 02111-1307 or on the worldwide web at http://www.gnu.org/licenses/gpl.txt.
15 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
17 * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
18 * this warranty disclaimer.
21 /****************************************************************************
23 03/01/08: Initial creation
24 ****************************************************************************/
26 /****************************************************************************
28 ****************************************************************************/
29 #include <sys/types.h>
31 #include <sys/socket.h>
32 #include <sys/select.h>
35 #include <netinet/in.h>
40 #include <sys/ioctl.h>
45 extern struct option cmd_options[];
47 /****************************************************************************
49 ****************************************************************************/
51 * @brief Show usage information for the sys_cfg_ap_mac_address
57 print_sys_cfg_ap_mac_address_usage(void)
59 printf("\nUsage : sys_cfg_ap_mac_address [AP_MAC_ADDRESS]\n");
61 ("\nIf AP_MAC_ADDRESS is provided, a 'set' is performed, else a 'get' is performed.\n");
66 * @brief Show usage information for the sys_cfg_ssid command
71 print_sys_cfg_ssid_usage(void)
73 printf("\nUsage : sys_cfg_ssid [SSID]\n");
75 ("\nIf SSID is provided, a 'set' is performed, else a 'get' is performed.\n");
80 * @brief Show usage information for the sys_cfg_beacon_period
86 print_sys_cfg_beacon_period_usage(void)
88 printf("\nUsage : sys_cfg_beacon_period [BEACON_PERIOD]\n");
90 ("\nIf BEACON_PERIOD is provided, a 'set' is performed, else a 'get' is performed.\n");
95 * @brief Show usage information for the sys_cfg_dtim_period
101 print_sys_cfg_dtim_period_usage(void)
103 printf("\nUsage : sys_cfg_dtim_period [DTIM_PERIOD]\n");
105 ("\nIf DTIM_PERIOD is provided, a 'set' is performed, else a 'get' is performed.\n");
110 * @brief Show usage information for the sys_cfg_channel
116 print_sys_cfg_channel_usage(void)
118 printf("\nUsage : sys_cfg_channel [CHANNEL] [MODE]\n");
120 ("\nIf CHANNEL is provided, a 'set' is performed, else a 'get' is performed.");
121 printf("\nIf MODE is provided, 0 for manual channel selection,");
122 printf("\nelse ACS (automatic channel selection) is performed\n");
127 * @brief Show usage information for the sys_cfg_scan_channels
133 print_sys_cfg_scan_channels_usage(void)
135 printf("\nUsage : sys_cfg_scan_channels [CHANNELS]\n");
137 ("\nIf CHANNELS are provided, a 'set' is performed, else a 'get' is performed.\n");
142 * @brief Show usage information for the sys_cfg_rates_ext command
147 print_sys_cfg_rates_ext_usage(void)
150 ("\nUsage : sys_cfg_rates_ext [rates RATES] [mbrate RATE] [urate RATE]\n");
152 ("\nIf 'Rate' provided, a 'set' is performed else a 'get' is performed");
154 ("\nRATES is provided as a set of data rates, in unit of 500 kilobits");
155 printf("\nA rate with MSB bit is basic rate, i.e 0x82 is basic rate.\n");
156 printf("\nFollowing is the list of supported rates in units of 500 Kbps:");
157 printf("\nDecimal: (2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108)");
159 ("\nHex: (0x02, 0x04, 0x0b, 0x16, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6c)");
161 ("\nBasic rates: (0x82, 0x84, 0x8b, 0x96, 0x8C, 0x92, 0x98, 0xA4, 0xB0, 0xC8, 0xE0, 0xEc)\n");
163 ("\nRates 2, 4, 11 and 22 (in units of 500 Kbps) must be present in either of basic or");
165 ("\nnon-basic rates. If OFDM rates are enabled then 12, 24 and 48 (in units of 500 Kbps)");
166 printf("\nmust be present in either basic or non-basic rates");
167 printf("\nEach rate must be separated by a space.");
168 printf("\nrates followed by RATES for setting operational rates.");
170 ("\nmbrate followed by RATE for setting multicast and broadcast rate.");
171 printf("\nurate followed by RATE for setting unicast rate.\n");
176 * @brief Show usage information for the sys_cfg_rates command
181 print_sys_cfg_rates_usage(void)
183 printf("\nUsage : sys_cfg_rates [RATES]\n");
185 ("\n[RATES] is set of data rates in unit of 500 kbps and each rate can be");
187 ("\nentered in hexadecimal or decimal format. Rates must be separated by");
188 printf("\nspace. Duplicate Rate fields are not allowed");
189 printf("\nA rate with MSB bit is basic rate, i.e 0x82 is basic rate.");
190 printf("\nFollowing is the list of supported rates in units of 500 Kbps:");
191 printf("\nDecimal: (2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108)");
193 ("\nHex: (0x02, 0x04, 0x0b, 0x16, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6c)");
195 ("\nBasic rates: (0x82, 0x84, 0x8b, 0x96, 0x8C, 0x92, 0x98, 0xA4, 0xB0, 0xC8, 0xE0, 0xEc)\n");
200 * @brief Show usage information for the sys_cfg_tx_power
206 print_sys_cfg_tx_power_usage(void)
208 printf("\nUsage : sys_cfg_tx_power [TX_POWER]\n");
210 ("\nIf TX_POWER is provided, a 'set' is performed, else a 'get' is performed.");
211 printf("\nTX_POWER is represented in dBm.\n");
216 * @brief Show usage information for the sys_cfg_bcast_ssid_ctl
222 print_sys_cfg_bcast_ssid_ctl_usage(void)
224 printf("\nUsage : sys_cfg_bcast_ssid_ctl [0|1]\n");
225 printf("\nOptions: 0 - Disable SSID broadcast");
226 printf("\n 1 - Enable SSID broadcast");
227 printf("\n empty - Get current SSID broadcast setting\n");
232 * @brief Show usage information for the sys_cfg_rsn_replay_prot
238 print_sys_cfg_rsn_replay_prot_usage(void)
240 printf("\nUsage : sys_cfg_rsn_replay_prot [0|1]\n");
241 printf("\nOptions: 0 - Disable RSN replay protection");
242 printf("\n 1 - Enable RSN replay protection");
243 printf("\n empty - Get current RSN replay protection setting\n");
248 * @brief Show usage information for the sys_cfg_preamble_ctl
254 print_sys_cfg_preamble_ctl_usage(void)
256 printf("\nUsage : sys_cfg_preamble_ctl\n");
261 * @brief Show usage information for the sys_cfg_antenna_ctl
267 print_sys_cfg_antenna_ctl_usage(void)
269 printf("\nUsage : sys_cfg_antenna_ctl <ANTENNA> [MODE]\n");
270 printf("\nOptions: ANTENNA : 0 - Rx antenna");
271 printf("\n 1 - Tx antenna");
272 printf("\n MODE : 0 - Antenna A");
273 printf("\n 1 - Antenna B");
274 printf("\n empty - Get current antenna settings\n");
279 * @brief Show usage information for the sys_cfg_rts_threshold
285 print_sys_cfg_rts_threshold_usage(void)
287 printf("\nUsage : sys_cfg_rts_threshold [RTS_THRESHOLD]\n");
289 ("\nIf RTS_THRESHOLD is provided, a 'set' is performed, else a 'get' is performed.\n");
294 * @brief Show usage information for the sys_cfg_frag_threshold
300 print_sys_cfg_frag_threshold_usage(void)
302 printf("\nUsage : sys_cfg_frag_threshold [FRAG_THRESHOLD]\n");
304 ("\nIf FRAG_THRESHOLD is provided, a 'set' is performed, else a 'get' is performed.");
305 printf("\nFragment threshold should between 256 and 2346.\n");
310 * @brief Show usage information for the sys_cfg_radio_ctl
316 print_sys_cfg_radio_ctl_usage(void)
318 printf("\nUsage : sys_cfg_radio_ctl [0|1]\n");
319 printf("\nOptions: 0 - Turn radio on");
320 printf("\n 1 - Turn radio off");
321 printf("\n empty - Get current radio setting\n");
326 * @brief Show usage information for the sys_cfg_tx_data_rate
332 print_sys_cfg_tx_data_rates_usage(void)
334 printf("\nUsage : sys_cfg_tx_data_rate [TX_DATA_RATE]\n");
335 printf("\nOptions: 0 - Auto rate");
336 printf("\n >0 - Set specified data rate");
337 printf("\n empty - Get current data rate");
338 printf("\nFollowing is the list of supported rates in units of 500 Kbps");
339 printf("\nDecimal: (2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108)");
341 ("\nHex: (0x02, 0x04, 0x0b, 0x16, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6c)");
342 printf("\nOnly zero or rates currently configured are allowed.\n");
347 * @brief Show usage information for the sys_cfg_mcbc_data_rate
353 print_sys_cfg_mcbc_data_rates_usage(void)
355 printf("\nUsage : sys_cfg_mcbc_data_rate [MCBC_DATA_RATE]\n");
356 printf("\nOptions: 0 - Auto rate");
357 printf("\n >0 - Set specified MCBC data rate");
358 printf("\n empty - Get current MCBC data rate");
359 printf("\nFollowing is the list of supported rates in units of 500 Kbps");
360 printf("\nDecimal: (2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108)");
362 ("\nHex: (0x02, 0x04, 0x0b, 0x16, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6c)");
364 ("\nOnly zero or one of the basic rates currently configured are allowed.\n");
369 * @brief Show usage information for the sys_cfg_auth command
374 print_sys_cfg_auth_usage(void)
376 printf("\nUsage : sys_cfg_auth [AUTHMODE]\n");
377 printf("\nOptions: AUTHMODE : 0 - Open authentication");
378 printf("\n 1 - Shared key authentication");
379 printf("\n empty - Get current authenticaton mode\n");
384 * @brief Show usage information for the sys_cfg_pkt_fwd_ctl command
389 print_sys_cfg_pkt_fwd_ctl_usage(void)
391 printf("\nUsage : sys_cfg_pkt_fwd_ctl [0|1]\n");
392 printf("\nOptions: 0 - Forward all packets to the host");
393 printf("\n 1 - Firmware handles intra-BSS packets");
394 printf("\n empty - Get current packet forwarding setting\n");
399 * @brief Show usage information for the sys_cfg_sta_ageout_timer
405 print_sys_cfg_sta_ageout_timer_usage(void)
407 printf("\nUsage : sys_cfg_sta_ageout_timer [STA_AGEOUT_TIMER]\n");
409 ("\nIf STA_AGEOUT_TIMER is provided, a 'set' is performed, else a 'get' is performed.");
410 printf("\nSTA_AGEOUT_TIMER is represented in units of 100 ms.");
411 printf("\nValue of 0 will mean that stations will never be aged out.");
412 printf("\nThe value should between 300 and 864000.\n");
417 * @brief Show usage information for the sys_cfg_protocol command
422 print_sys_cfg_protocol_usage(void)
424 printf("\nUsage : sys_cfg_protocol [PROTOCOL]\n");
425 printf("\nOptions: PROTOCOL: 1 - No RSN");
426 printf("\n 2 - WEP Static");
427 printf("\n 8 - WPA");
428 printf("\n 32 - WPA2");
429 printf("\n 40 - WPA2 Mixed");
430 printf("\n empty - Get current protocol\n");
435 * @brief Show usage information for the sys_cfg_wep_key
441 print_sys_cfg_wep_key_usage(void)
443 printf("\nUsage : sys_cfg_wep_key ");
445 ("[INDEX_0 IS_DEFAULT KEY_0] [INDEX_1 IS_DEFAULT KEY_1] [INDEX_2 IS_DEFAULT KEY_2] [INDEX_3 IS_DEFAULT KEY_3]\n");
446 printf("[Index_0] [Index_1] [Index_2] [Index_3]\n");
447 printf("\nOptions: INDEX_* : 0 - KeyIndex is 0");
448 printf("\n 1 - KeyIndex is 1");
449 printf("\n 2 - KeyIndex is 2");
450 printf("\n 3 - KeyIndex is 3");
451 printf("\n IS_DEFAULT : 0 - KeyIndex is not the default");
453 ("\n 1 - KeyIndex is the default transmit key");
454 printf("\n KEY_* : Key value");
455 printf("\n Index_*: 0 - Get key 0 setting");
456 printf("\n 1 - Get key 1 setting");
457 printf("\n 2 - Get key 2 setting");
458 printf("\n 3 - Get key 3 setting");
459 printf("\n empty - Get current WEP key settings\n");
464 * @brief Show usage information for the sys_cfg_custom_ie
470 print_sys_cfg_custom_ie_usage(void)
472 printf("\nUsage : sys_cfg_custom_ie [INDEX] [MASK] [IEBuffer]");
473 printf("\n empty - Get all IE settings\n");
474 printf("\n INDEX: 0 - Get/Set IE index 0 setting");
475 printf("\n 1 - Get/Set IE index 1 setting");
476 printf("\n 2 - Get/Set IE index 2 setting");
477 printf("\n 3 - Get/Set IE index 3 setting");
479 ("\n MASK : Management subtype mask value as per bit defintions");
480 printf("\n : Bit 0 - Association request.");
481 printf("\n : Bit 1 - Association response.");
482 printf("\n : Bit 2 - Reassociation request.");
483 printf("\n : Bit 3 - Reassociation response.");
484 printf("\n : Bit 4 - Probe request.");
485 printf("\n : Bit 5 - Probe response.");
486 printf("\n : Bit 8 - Beacon.");
487 printf("\n MASK : MASK = 0 to clear the mask and the IE buffer");
488 printf("\n IEBuffer : IE Buffer in hex (max 256 bytes)\n\n");
492 /* @brief Show usage information for the sys_cfg_cipher * command * * $return
495 print_sys_cfg_cipher_usage(void)
497 printf("\nUsage : sys_cfg_cipher [PAIRWISE_CIPHER GROUP_CIPHER]\n");
498 printf("\nOptions: PAIRWISE_CIPHER: 0 - NONE");
499 printf("\n 4 - TKIP");
500 printf("\n 8 - AES CCMP");
501 printf("\n 12 - AES CCMP + TKIP");
502 printf("\n GROUP_CIPHER : 0 - NONE");
503 printf("\n 4 - TKIP");
504 printf("\n 8 - AES CCMP");
505 printf("\n empty - Get current cipher settings\n");
510 * @brief Show usage information for the sys_cfg_group_rekey_timer command
515 print_sys_cfg_group_rekey_timer_usage(void)
517 printf("\nUsage : sys_cfg_group_rekey_timer [GROUP_REKEY_TIMER]\n");
518 printf("\nOptions: GROUP_REKEY_TIME is represented in seconds");
519 printf("\n empty - Get current group re-key time\n");
524 * @brief Show usage information for the sys_cfg_wpa_passphrase
530 print_sys_cfg_wpa_passphrase_usage(void)
532 printf("\nUsage : sys_cfg_wpa_passphrase [PASSPHRASE]\n");
534 ("\nIf PASSPHRASE is provided, a 'set' is performed, else a 'get' is performed.\n");
539 * @brief Show usage information for the sta_filter_table command
544 print_sta_filter_table_usage(void)
546 printf("\nUsage : sta_filter_table <FILTERMODE> <MACADDRESS_LIST>\n");
547 printf("\nOptions: FILTERMODE : 0 - Disable filter table");
549 ("\n 1 - allow MAC addresses specified in the allowed list");
551 ("\n 2 - block MAC addresses specified in the banned list");
553 ("\n MACADDRESS_LIST is the list of MAC addresses to be acted upon. Each");
555 ("\n MAC address must be separated with a space. Maximum of");
556 printf("\n 16 MAC addresses are supported.");
557 printf("\n empty - Get current mac filter settings\n");
562 * @brief Show usage information for the sys_cfg_max_sta_num command
567 print_sys_cfg_max_sta_num_usage(void)
569 printf("\nUsage : sys_cfg_max_sta_num [STA_NUM]\n");
571 ("\nIf STA_NUM is provided, a 'set' is performed, else a 'get' is performed.");
572 printf("\nSTA_NUM should not bigger than 8.\n");
577 * @brief Show usage information for the sys_cfg_retry_limit command
582 print_sys_cfg_retry_limit_usage(void)
584 printf("\nUsage : sys_cfg_retry_limit [RETRY_LIMIT]\n");
586 ("\nIf RETRY_LIMIT is provided, a 'set' is performed, else a 'get' is performed.");
587 printf("\nRETRY_LIMIT should not bigger than 14.\n");
592 * @brief Show usage information for the sys_cfg_retry_limit command
597 print_cfg_data_usage(void)
599 printf("\nUsage : cfg_data <type> [*.conf]\n");
600 printf("\n type : 2 -- cal data");
601 printf("\n *.conf : file contain configuration data");
602 printf("\n empty - get current configuration data\n");
607 * @brief get configured operational rates.
609 * @param rates Operational rates allowed are
610 * stored at this pointer
611 * @return number of basic rates allowed.
615 get_sys_cfg_rates(u8 * rates)
617 APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
618 TLVBUF_RATES *tlv = NULL;
621 int ret = UAP_FAILURE;
624 /* Initialize the command length */
626 sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_RATES) + MAX_DATA_RATES;
627 /* Initialize the command buffer */
628 buffer = (u8 *) malloc(cmd_len);
630 printf("ERR:Cannot allocate buffer for command!\n");
633 bzero((char *) buffer, cmd_len);
636 cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
637 tlv = (TLVBUF_RATES *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));
639 /* Fill the command buffer */
640 cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
641 cmd_buf->Size = cmd_len;
644 tlv->Tag = MRVL_RATES_TLV_ID;
645 cmd_buf->Action = ACTION_GET;
646 tlv->Length = MAX_DATA_RATES;
648 endian_convert_tlv_header_out(tlv);
649 /* Send the command */
650 ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
651 endian_convert_tlv_header_in(tlv);
652 /* Process response */
653 if (ret == UAP_SUCCESS) {
654 /* Verify response */
655 if ((cmd_buf->CmdCode != (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) ||
656 (tlv->Tag != MRVL_RATES_TLV_ID)) {
657 printf("ERR:Corrupted response! CmdCode=%x, Tlv->Tag=%x\n",
658 cmd_buf->CmdCode, tlv->Tag);
664 if (cmd_buf->Result == CMD_SUCCESS) {
665 for (i = 0; i < tlv->Length; i++) {
666 if (tlv->OperationalRates[i] != 0) {
667 rates[rate_cnt++] = tlv->OperationalRates[i];
671 printf("ERR:Could not get operational rates!\n");
674 printf("ERR:Command sending failed!\n");
682 * @brief check rate is valid or not.
684 * @param rate rate for check
686 * @return UAP_SUCCESS or UAP_FAILURE
689 is_tx_rate_valid(u8 rate)
693 u8 rates[MAX_DATA_RATES];
695 rate_cnt = get_sys_cfg_rates((u8 *) & rates);
697 for (i = 0; i < rate_cnt; i++) {
698 if (rate == (rates[i] & ~BASIC_RATE_SET_BIT)) {
707 * @brief check mcbc rate is valid or not.
709 * @param rate rate for check
711 * @return UAP_SUCCESS or UAP_FAILURE
714 is_mcbc_rate_valid(u8 rate)
718 u8 rates[MAX_DATA_RATES];
720 rate_cnt = get_sys_cfg_rates((u8 *) & rates);
722 for (i = 0; i < rate_cnt; i++) {
723 if (rates[i] & BASIC_RATE_SET_BIT) {
724 if (rate == (rates[i] & ~BASIC_RATE_SET_BIT)) {
733 /****************************************************************************
735 ****************************************************************************/
737 * @brief Creates a sys_cfg request for AP MAC address
738 * and sends to the driver
740 * Usage: "sys_cfg_ap_mac_address [AP_MAC_ADDRESS]"
741 * if AP_MAC_ADDRESS is provided, a 'set' is performed,
742 * else a 'get' is performed.
744 * @param argc Number of arguments
745 * @param argv Pointer to the arguments
749 apcmd_sys_cfg_ap_mac_address(int argc, char *argv[])
751 APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
752 TLVBUF_AP_MAC_ADDRESS *tlv = NULL;
755 int ret = UAP_FAILURE;
758 while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
761 print_sys_cfg_ap_mac_address_usage();
768 /* Check arguments */
770 printf("ERR:Too many arguments.\n");
771 print_sys_cfg_ap_mac_address_usage();
775 /* Initialize the command length */
776 cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_AP_MAC_ADDRESS);
778 /* Initialize the command buffer */
779 buffer = (u8 *) malloc(cmd_len);
782 printf("ERR:Cannot allocate buffer for command!\n");
785 bzero((char *) buffer, cmd_len);
788 cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
789 tlv = (TLVBUF_AP_MAC_ADDRESS *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));
791 /* Fill the command buffer */
792 cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
793 cmd_buf->Size = cmd_len;
796 tlv->Tag = MRVL_AP_MAC_ADDRESS_TLV_ID;
797 tlv->Length = ETH_ALEN;
799 cmd_buf->Action = ACTION_GET;
801 cmd_buf->Action = ACTION_SET;
802 if ((ret = mac2raw(argv[0], tlv->ApMacAddr)) != UAP_SUCCESS) {
803 printf("ERR: %s Address \n", ret == UAP_FAILURE ? "Invalid MAC" :
804 ret == UAP_RET_MAC_BROADCAST ? "Broadcast" : "Multicast");
809 endian_convert_tlv_header_out(tlv);
811 /* Send the command */
812 ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
813 endian_convert_tlv_header_in(tlv);
814 /* Process response */
815 if (ret == UAP_SUCCESS) {
816 /* Verify response */
817 if ((cmd_buf->CmdCode != (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) ||
818 (tlv->Tag != MRVL_AP_MAC_ADDRESS_TLV_ID)) {
819 printf("ERR:Corrupted response! CmdCode=%x, Tlv->Tag=%x\n",
820 cmd_buf->CmdCode, tlv->Tag);
826 if (cmd_buf->Result == CMD_SUCCESS) {
828 printf("AP MAC address = ");
829 print_mac(tlv->ApMacAddr);
832 printf("AP MAC address setting successful\n");
836 printf("ERR:Could not get AP MAC address!\n");
838 printf("ERR:Could not set AP MAC address!\n");
842 printf("ERR:Command sending failed!\n");
851 * @brief Creates a sys_cfg request for SSID
852 * and sends to the driver
854 * Usage: "sys_cfg_ssid [SSID]"
855 * if SSID is provided, a 'set' is performed
856 * else a 'get' is performed
858 * @param argc Number of arguments
859 * @param argv Pointer to the arguments
863 apcmd_sys_cfg_ssid(int argc, char *argv[])
865 APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
866 TLVBUF_SSID *tlv = NULL;
869 int ret = UAP_FAILURE;
873 while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
876 print_sys_cfg_ssid_usage();
883 /* Check arguments */
885 printf("ERR:Too many arguments.\n");
886 print_sys_cfg_ssid_usage();
891 /* Initialize the command length */
893 sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_SSID) +
896 if (strlen(argv[0]) > MAX_SSID_LENGTH) {
897 printf("ERR:SSID too long.\n");
900 /* Initialize the command length */
901 if (argv[0][1] == '"') {
904 if (argv[0][strlen(argv[0])] == '"') {
905 argv[0][strlen(argv[0])] = '\0';
907 if (!strlen(argv[0])) {
908 printf("ERR:NULL SSID not allowed.\n");
912 sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_SSID) +
916 /* Initialize the command buffer */
917 buffer = (u8 *) malloc(cmd_len);
920 printf("ERR:Cannot allocate buffer for command!\n");
923 bzero((char *) buffer, cmd_len);
926 cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
927 tlv = (TLVBUF_SSID *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));
929 /* Fill the command buffer */
930 cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
931 cmd_buf->Size = cmd_len;
934 tlv->Tag = MRVL_SSID_TLV_ID;
936 cmd_buf->Action = ACTION_GET;
937 tlv->Length = MAX_SSID_LENGTH;
939 cmd_buf->Action = ACTION_SET;
940 tlv->Length = strlen(argv[0]);
941 memcpy(tlv->Ssid, argv[0], tlv->Length);
944 endian_convert_tlv_header_out(tlv);
946 /* Send the command */
947 ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
949 endian_convert_tlv_header_in(tlv);
951 /* Process response */
952 if (ret == UAP_SUCCESS) {
953 /* Verify response */
954 if ((cmd_buf->CmdCode != (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) ||
955 (tlv->Tag != MRVL_SSID_TLV_ID)) {
956 printf("ERR:Corrupted response! CmdCode=%x, Tlv->Tag=%x\n",
957 cmd_buf->CmdCode, tlv->Tag);
963 if (cmd_buf->Result == CMD_SUCCESS) {
965 memset(ssid, 0, sizeof(ssid));
966 memcpy(ssid, tlv->Ssid, tlv->Length);
967 printf("SSID = %s\n", ssid);
969 printf("SSID setting successful\n");
973 printf("ERR:Could not get SSID!\n");
975 printf("ERR:Could not set SSID!\n");
979 printf("ERR:Command sending failed!\n");
988 * @brief Creates a sys_cfg request for beacon period
989 * and sends to the driver
991 * Usage: "sys_cfg_beacon_period [BEACON_PERIOD]"
992 * if BEACON_PERIOD is provided, a 'set' is performed
993 * else a 'get' is performed.
995 * BEACON_PERIOD is represented in ms
997 * @param argc Number of arguments
998 * @param argv Pointer to the arguments
1002 apcmd_sys_cfg_beacon_period(int argc, char *argv[])
1004 APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
1005 TLVBUF_BEACON_PERIOD *tlv = NULL;
1008 int ret = UAP_FAILURE;
1011 while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
1014 print_sys_cfg_beacon_period_usage();
1021 /* Check arguments */
1022 if (argc && is_input_valid(BEACONPERIOD, argc, argv) != UAP_SUCCESS) {
1023 print_sys_cfg_beacon_period_usage();
1026 /* Initialize the command length */
1027 cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_BEACON_PERIOD);
1029 /* Initialize the command buffer */
1030 buffer = (u8 *) malloc(cmd_len);
1033 printf("ERR:Cannot allocate buffer for command!\n");
1036 bzero((char *) buffer, cmd_len);
1038 /* Locate headers */
1039 cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
1040 tlv = (TLVBUF_BEACON_PERIOD *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));
1042 /* Fill the command buffer */
1043 cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
1044 cmd_buf->Size = cmd_len;
1045 cmd_buf->SeqNum = 0;
1046 cmd_buf->Result = 0;
1047 tlv->Tag = MRVL_BEACON_PERIOD_TLV_ID;
1050 cmd_buf->Action = ACTION_GET;
1052 cmd_buf->Action = ACTION_SET;
1053 tlv->BeaconPeriod_ms = (u16) atoi(argv[0]);
1055 endian_convert_tlv_header_out(tlv);
1056 tlv->BeaconPeriod_ms = uap_cpu_to_le16(tlv->BeaconPeriod_ms);
1058 /* Send the command */
1059 ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
1060 endian_convert_tlv_header_in(tlv);
1061 tlv->BeaconPeriod_ms = uap_le16_to_cpu(tlv->BeaconPeriod_ms);
1062 /* Process response */
1063 if (ret == UAP_SUCCESS) {
1064 /* Verify response */
1065 if ((cmd_buf->CmdCode != (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) ||
1066 (tlv->Tag != MRVL_BEACON_PERIOD_TLV_ID)) {
1067 printf("ERR:Corrupted response! CmdCode=%x, Tlv->Tag=%x\n",
1068 cmd_buf->CmdCode, tlv->Tag);
1072 /* Print response */
1073 if (cmd_buf->Result == CMD_SUCCESS) {
1075 printf("Beacon period = %d\n", tlv->BeaconPeriod_ms);
1077 printf("Beacon period setting successful\n");
1081 printf("ERR:Could not get beacon period!\n");
1083 printf("ERR:Could not set beacon period!\n");
1087 printf("ERR:Command sending failed!\n");
1095 * @brief Creates a sys_cfg request for DTIM period
1096 * and sends to the driver
1098 * Usage: "sys_cfg_dtim_period [DTIM_PERIOD]"
1099 * if DTIM_PERIOD is provided, a 'set' is performed
1100 * else a 'get' is performed
1102 * @param argc Number of arguments
1103 * @param argv Pointer to the arguments
1107 apcmd_sys_cfg_dtim_period(int argc, char *argv[])
1109 APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
1110 TLVBUF_DTIM_PERIOD *tlv = NULL;
1113 int ret = UAP_FAILURE;
1115 while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
1118 print_sys_cfg_dtim_period_usage();
1124 /* Check arguments */
1125 if (argc && (is_input_valid(DTIMPERIOD, argc, argv) != UAP_SUCCESS)) {
1126 print_sys_cfg_dtim_period_usage();
1130 /* Initialize the command length */
1131 cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_DTIM_PERIOD);
1133 /* Initialize the command buffer */
1134 buffer = (u8 *) malloc(cmd_len);
1137 printf("ERR:Cannot allocate buffer for command!\n");
1140 bzero((char *) buffer, cmd_len);
1142 /* Locate headers */
1143 cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
1144 tlv = (TLVBUF_DTIM_PERIOD *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));
1146 /* Fill the command buffer */
1147 cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
1148 cmd_buf->Size = cmd_len;
1149 cmd_buf->SeqNum = 0;
1150 cmd_buf->Result = 0;
1151 tlv->Tag = MRVL_DTIM_PERIOD_TLV_ID;
1154 cmd_buf->Action = ACTION_GET;
1156 cmd_buf->Action = ACTION_SET;
1157 tlv->DtimPeriod = (u8) atoi(argv[0]);
1159 endian_convert_tlv_header_out(tlv);
1160 /* Send the command */
1161 ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
1162 endian_convert_tlv_header_in(tlv);
1164 /* Process response */
1165 if (ret == UAP_SUCCESS) {
1166 /* Verify response */
1167 if ((cmd_buf->CmdCode != (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) ||
1168 (tlv->Tag != MRVL_DTIM_PERIOD_TLV_ID)) {
1169 printf("ERR:Corrupted response! CmdCode=%x, Tlv->Tag=%x\n",
1170 cmd_buf->CmdCode, tlv->Tag);
1174 /* Print response */
1175 if (cmd_buf->Result == CMD_SUCCESS) {
1177 printf("DTIM period = %d\n", tlv->DtimPeriod);
1179 printf("DTIM period setting successful\n");
1183 printf("ERR:Could not get DTIM period!\n");
1185 printf("ERR:Could not set DTIM period!\n");
1189 printf("ERR:Command sending failed!\n");
1197 * @brief Creates a sys_cfg request for channel
1198 * and sends to the driver
1200 * Usage: "sys_cfg_channel [CHANNEL] [MODE]"
1201 * if CHANNEL is provided, a 'set' is performed
1202 * else a 'get' is performed
1203 * if MODE is provided, a 'set' is performed with
1204 * 0 as manual channel selection
1205 * 1 as automatic channel selection.
1207 * @param argc Number of arguments
1208 * @param argv Pointer to the arguments
1212 apcmd_sys_cfg_channel(int argc, char *argv[])
1214 APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
1215 TLVBUF_CHANNEL_CONFIG *tlv = NULL;
1218 int ret = UAP_FAILURE;
1220 while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
1223 print_sys_cfg_channel_usage();
1230 /* Check arguments */
1231 if (argc && is_input_valid(CHANNEL, argc, argv) != UAP_SUCCESS) {
1232 print_sys_cfg_channel_usage();
1236 /* Initialize the command length */
1237 cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_CHANNEL_CONFIG);
1239 /* Initialize the command buffer */
1240 buffer = (u8 *) malloc(cmd_len);
1243 printf("ERR:Cannot allocate buffer for command!\n");
1246 bzero((char *) buffer, cmd_len);
1248 /* Locate headers */
1249 cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
1250 tlv = (TLVBUF_CHANNEL_CONFIG *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));
1252 /* Fill the command buffer */
1253 cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
1254 cmd_buf->Size = cmd_len;
1255 cmd_buf->SeqNum = 0;
1256 cmd_buf->Result = 0;
1257 tlv->Tag = MRVL_CHANNELCONFIG_TLV_ID;
1260 cmd_buf->Action = ACTION_GET;
1262 cmd_buf->Action = ACTION_SET;
1264 tlv->ChanNumber = (u8) atoi(argv[0]);
1265 tlv->BandConfigType = 0;
1267 tlv->BandConfigType = atoi(argv[1]) ? BAND_CONFIG_ACS_MODE : 0;
1268 tlv->ChanNumber = (u8) atoi(argv[0]);
1271 endian_convert_tlv_header_out(tlv);
1272 /* Send the command */
1273 ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
1274 endian_convert_tlv_header_in(tlv);
1275 /* Process response */
1276 if (ret == UAP_SUCCESS) {
1277 /* Verify response */
1278 if ((cmd_buf->CmdCode != (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) ||
1279 (tlv->Tag != MRVL_CHANNELCONFIG_TLV_ID)) {
1280 printf("ERR:Corrupted response! CmdCode=%x, Tlv->Tag=%x\n",
1281 cmd_buf->CmdCode, tlv->Tag);
1285 /* Print response */
1286 if (cmd_buf->Result == CMD_SUCCESS) {
1288 printf("Mode = %s\n",
1289 (tlv->BandConfigType == 0) ? "Manual" : "ACS");
1290 printf("Channel = %d\n", tlv->ChanNumber);
1292 printf("Channel setting successful\n");
1296 printf("ERR:Could not get channel!\n");
1298 printf("ERR:Could not set channel!\n");
1302 printf("ERR:Command sending failed!\n");
1310 * @brief Creates a sys_cfg request for channel list
1311 * and sends to the driver
1313 * Usage: "sys_cfg_scan_channels [CHANNELS]"
1314 * if CHANNELS are provided, a 'set' is performed
1315 * else a 'get' is performed
1317 * @param argc Number of arguments
1318 * @param argv Pointer to the arguments
1322 apcmd_sys_cfg_scan_channels(int argc, char *argv[])
1324 APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
1325 TLVBUF_CHANNEL_LIST *tlv = NULL;
1326 CHANNEL_LIST *pChanList = NULL;
1329 int ret = UAP_FAILURE;
1332 while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
1335 print_sys_cfg_scan_channels_usage();
1342 /* Check arguments */
1343 if (argc && is_input_valid(SCANCHANNELS, argc, argv) != UAP_SUCCESS) {
1344 print_sys_cfg_scan_channels_usage();
1348 /* Initialize the command length */
1351 sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_CHANNEL_LIST) +
1352 sizeof(CHANNEL_LIST) * MAX_CHANNELS;
1355 sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_CHANNEL_LIST) +
1356 sizeof(CHANNEL_LIST) * argc;
1358 /* Initialize the command buffer */
1359 buffer = (u8 *) malloc(cmd_len);
1362 printf("ERR:Can not allocate buffer for command!\n");
1365 bzero((char *) buffer, cmd_len);
1367 /* LOCATE HEADERS */
1368 cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
1369 tlv = (TLVBUF_CHANNEL_LIST *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));
1371 /* Fill the command buffer */
1372 cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
1373 cmd_buf->Size = cmd_len;
1374 cmd_buf->SeqNum = 0;
1375 cmd_buf->Result = 0;
1376 tlv->Tag = MRVL_CHANNELLIST_TLV_ID;
1378 cmd_buf->Action = ACTION_GET;
1379 tlv->Length = sizeof(CHANNEL_LIST) * MAX_CHANNELS;
1381 cmd_buf->Action = ACTION_SET;
1382 tlv->Length = sizeof(CHANNEL_LIST) * argc;
1383 pChanList = tlv->ChanList;
1384 for (i = 0; i < argc; i++) {
1385 pChanList->ChanNumber = (u8) atoi(argv[i]);
1386 pChanList->BandConfigType = 0;
1390 endian_convert_tlv_header_out(tlv);
1391 /* Send the command */
1392 ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
1393 endian_convert_tlv_header_in(tlv);
1394 /* Process response */
1395 if (ret == UAP_SUCCESS) {
1396 /* Verify response */
1397 if ((cmd_buf->CmdCode != (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) ||
1398 (tlv->Tag != MRVL_CHANNELLIST_TLV_ID)) {
1399 printf("ERR:Corrupted response! CmdCode=%x, Tlv->Tag=%x\n",
1400 cmd_buf->CmdCode, tlv->Tag);
1404 /* Print response */
1405 if (cmd_buf->Result == CMD_SUCCESS) {
1407 printf("Channels List = ");
1408 if (tlv->Length % sizeof(CHANNEL_LIST)) {
1409 printf("Error: Length mismatch\n");
1413 pChanList = tlv->ChanList;
1414 for (i = 0; i < (tlv->Length / sizeof(CHANNEL_LIST)); i++) {
1415 printf("%d ", pChanList->ChanNumber);
1420 printf("Scan Channel List setting successful\n");
1423 printf("ERR:Could not %s scan channel list!\n",
1424 argc ? "SET" : "GET");
1427 printf("ERR:Command sending failed!\n");
1435 * @brief parser for sys_cfg_rates_ext input
1437 * @param argc Number of arguments
1438 * @param argv Pointer to the arguments
1439 * @param output stores indexes for "rates, mbrate and urate"
1444 * "rates 0x82 4 16 22 0x30 mbrate 2 urate 16"
1446 * will have output array as
1448 * start_index end_index
1457 parse_input(int argc, char **argv, int output[3][2])
1460 char *keywords[3] = { "rates", "mbrate", "urate" };
1462 for (i = 0; i < 3; i++)
1465 for (i = 0; i < argc; i++) {
1466 for (j = 0; j < 3; j++) {
1467 if (strcmp(argv[i], keywords[j]) == 0) {
1468 output[j][1] = output[j][0] = i;
1478 * @brief Creates a sys_cfg request for setting data_rates, MCBC and
1481 * Usage: "sys_cfg_rates_ext [RATES]"
1483 * @param argc Number of arguments
1484 * @param argv Pointer to the arguments
1488 apcmd_sys_cfg_rates_ext(int argc, char *argv[])
1492 int rflag = 0, mflag = 0, uflag = 0;
1493 char *argv_rate[14];
1495 char *argv_mrate[1];
1496 char *argv_urate[1];
1497 int mrate_found = UAP_FAILURE;
1498 int urate_found = UAP_FAILURE;
1500 TLVBUF_TX_DATA_RATE *tlv_urate = NULL;
1501 TLVBUF_MCBC_DATA_RATE *tlv_mrate = NULL;
1502 TLVBUF_RATES *tlv_rate = NULL;
1504 APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
1505 int ret = UAP_FAILURE;
1509 while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
1512 print_sys_cfg_rates_ext_usage();
1523 parse_input(argc, argv, output);
1528 if ((output[0][0] != -1) && (output[0][1] > output[0][0])) {
1531 for (j = (output[0][0] + 1); j < output[0][1]; j++) {
1533 (char *) malloc(sizeof(char) * (strlen(argv[j]) + 1));
1534 strcpy(argv_rate[i], argv[j]);
1543 if ((output[1][0] != -1) && (output[1][1] > output[1][0])) {
1544 if ((output[1][1] - output[1][0]) != 2) {
1545 printf("\nERR: Invalid mrate input");
1546 print_sys_cfg_rates_ext_usage();
1551 (char *) malloc(sizeof(char) * (strlen(argv[j]) + 1));
1552 strcpy(argv_mrate[0], argv[output[1][0] + 1]);
1558 if ((output[2][0] != -1) && (output[2][1] > output[2][0])) {
1559 if ((output[2][1] - output[2][0]) != 2) {
1560 printf("\nERR: Invalid urate input");
1561 print_sys_cfg_rates_ext_usage();
1566 (char *) malloc(sizeof(char) * (strlen(argv[j]) + 1));
1567 strcpy(argv_urate[0], argv[output[2][0] + 1]);
1570 if (!rflag && !mflag & !uflag) {
1571 printf("ERR: Invalid input\n");
1572 print_sys_cfg_rates_ext_usage();
1576 if (rflag && is_input_valid(RATE, argc_rate, argv_rate) != UAP_SUCCESS) {
1577 printf("ERR: Invalid RATE\n");
1578 print_sys_cfg_rates_ext_usage();
1582 if (mflag && is_input_valid(MCBCDATARATE, 1, argv_mrate) != UAP_SUCCESS) {
1583 printf("ERR: Invalid MCBC RATE\n");
1584 print_sys_cfg_rates_ext_usage();
1588 if (uflag && is_input_valid(TXDATARATE, 1, argv_urate) != UAP_SUCCESS) {
1589 printf("ERR: Invalid TX RATE\n");
1590 print_sys_cfg_rates_ext_usage();
1594 if (!rflag && (mflag || uflag)) {
1596 * Check mrate and urate wrt old Rates
1598 if (mflag && A2HEXDECIMAL(argv_mrate[0]) &&
1599 is_mcbc_rate_valid(A2HEXDECIMAL(argv_mrate[0])) !=
1601 printf("ERR: invalid MCBC data rate.");
1602 print_sys_cfg_rates_ext_usage();
1605 if (uflag && A2HEXDECIMAL(argv_urate[0]) &&
1606 is_tx_rate_valid(A2HEXDECIMAL(argv_urate[0])) != UAP_SUCCESS) {
1607 printf("ERR: invalid tx data rate.");
1608 print_sys_cfg_rates_ext_usage();
1611 } else if (rflag && (mflag || uflag)) {
1613 * Check mrate and urate wrt new Rates
1615 for (i = 0; i < argc_rate; i++) {
1617 * MCBC rate must be from Basic rates
1619 if (mflag && !mrate_found &&
1620 A2HEXDECIMAL(argv_rate[i]) & BASIC_RATE_SET_BIT) {
1621 if (A2HEXDECIMAL(argv_mrate[0]) ==
1622 (A2HEXDECIMAL(argv_rate[i]) & ~BASIC_RATE_SET_BIT)) {
1623 mrate_found = UAP_SUCCESS;
1626 if (uflag && !urate_found && (A2HEXDECIMAL(argv_urate[0]) ==
1627 ((A2HEXDECIMAL(argv_rate[i]) &
1628 ~BASIC_RATE_SET_BIT)))) {
1629 urate_found = UAP_SUCCESS;
1633 if (mflag && A2HEXDECIMAL(argv_mrate[0]) &&
1634 !(mrate_found == UAP_SUCCESS)) {
1635 printf("ERR: mrate not valid\n");
1639 if (uflag && A2HEXDECIMAL(argv_urate[0]) &&
1640 !(urate_found == UAP_SUCCESS)) {
1641 printf("ERR: urate not valid\n");
1646 cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE);
1648 cmd_len += sizeof(TLVBUF_RATES) + argc_rate;
1649 cmd_len += sizeof(TLVBUF_MCBC_DATA_RATE);
1650 cmd_len += sizeof(TLVBUF_TX_DATA_RATE);
1653 cmd_len += sizeof(TLVBUF_MCBC_DATA_RATE);
1655 cmd_len += sizeof(TLVBUF_TX_DATA_RATE);
1659 cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE)
1660 + sizeof(TLVBUF_RATES) + MAX_RATES + sizeof(TLVBUF_MCBC_DATA_RATE)
1661 + sizeof(TLVBUF_TX_DATA_RATE);
1664 buffer = (u8 *) malloc(cmd_len);
1666 printf("ERR:Cannot allocate buffer for command!\n");
1669 bzero((char *) buffer, cmd_len);
1671 /* Fill the command buffer */
1672 cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
1673 cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
1674 cmd_buf->Size = cmd_len;
1675 cmd_buf->SeqNum = 0;
1676 cmd_buf->Result = 0;
1677 cmd_buf->Action = argc ? ACTION_SET : ACTION_GET;
1678 tlv_buf = buffer + sizeof(APCMDBUF_SYS_CONFIGURE);
1679 /* Locate headers */
1680 if (rflag || (!argc)) {
1681 tlv_rate = (TLVBUF_RATES *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));
1682 tlv_rate->Tag = MRVL_RATES_TLV_ID;
1683 tlv_rate->Length = argc ? argc_rate : MAX_RATES;
1684 for (i = 0; i < argc_rate; i++) {
1685 tlv_rate->OperationalRates[i] = (u8) A2HEXDECIMAL(argv_rate[i]);
1687 tlv_buf += tlv_rate->Length + sizeof(TLVBUF_RATES);
1688 endian_convert_tlv_header_out(tlv_rate);
1690 if (rflag || mflag || (!argc)) {
1691 tlv_mrate = (TLVBUF_MCBC_DATA_RATE *) tlv_buf;
1692 tlv_mrate->Tag = MRVL_MCBC_DATA_RATE_TLV_ID;
1693 tlv_mrate->Length = 2;
1694 tlv_mrate->MCBCdatarate = 0;
1696 tlv_mrate->MCBCdatarate = (u16) A2HEXDECIMAL(argv_mrate[0])
1697 & ~BASIC_RATE_SET_BIT;
1698 tlv_mrate->MCBCdatarate = uap_cpu_to_le16(tlv_mrate->MCBCdatarate);
1700 tlv_buf += sizeof(TLVBUF_MCBC_DATA_RATE);
1701 endian_convert_tlv_header_out(tlv_mrate);
1703 if (rflag || uflag || (!argc)) {
1704 tlv_urate = (TLVBUF_TX_DATA_RATE *) tlv_buf;
1705 tlv_urate->Tag = MRVL_TX_DATA_RATE_TLV_ID;
1706 tlv_urate->Length = 2;
1707 tlv_urate->TxDataRate = 0;
1709 tlv_urate->TxDataRate = (u16) A2HEXDECIMAL(argv_urate[0])
1710 & ~BASIC_RATE_SET_BIT;
1711 tlv_urate->TxDataRate = uap_cpu_to_le16(tlv_urate->TxDataRate);
1713 endian_convert_tlv_header_out(tlv_urate);
1716 /* Send the command */
1717 ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
1719 tlv_buf = buffer + sizeof(APCMDBUF_SYS_CONFIGURE);
1721 if (ret == UAP_SUCCESS) {
1722 /* Verify response */
1723 if (cmd_buf->CmdCode != (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) {
1724 printf("ERR:Corrupted response! CmdCode=%x\n", cmd_buf->CmdCode);
1727 /* Print response */
1728 if (cmd_buf->Result == CMD_SUCCESS) {
1730 printf("Rates setting successful\n");
1732 print_tlv((u8 *) tlv_buf,
1733 cmd_buf->Size - sizeof(APCMDBUF_SYS_CONFIGURE) +
1737 printf("ERR:Could not %s operational rates!\n",
1738 argc ? "set" : "get");
1741 ("operational rates only allow to set before bss start.\n");
1744 printf("ERR:Command sending failed!\n");
1748 for (i = 0; i < argc_rate; i++) {
1753 free(argv_mrate[0]);
1755 free(argv_urate[0]);
1762 * @brief Creates a sys_cfg request for data rates
1763 * and sends to the driver
1765 * Usage: "sys_cfg_rates [RATES]"
1767 * RATES is provided as a set of data rates, in
1768 * unit of 500 kilobits/s.
1769 * Maximum 12 rates can be provided.
1771 * if no RATE is provided, then it gets configured rates
1773 * Each rate must be separated by a space
1775 * @param argc Number of arguments
1776 * @param argv Pointer to the arguments
1780 apcmd_sys_cfg_rates(int argc, char *argv[])
1782 APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
1783 TLVBUF_RATES *tlv = NULL;
1786 int ret = UAP_FAILURE;
1789 while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
1792 print_sys_cfg_rates_usage();
1799 /* Check arguments */
1800 if (argc && is_input_valid(RATE, argc, argv) != UAP_SUCCESS) {
1801 print_sys_cfg_rates_usage();
1805 /* Initialize the command length */
1807 sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_RATES) + MAX_RATES;
1809 /* Initialize the command length */
1810 cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_RATES) + argc;
1812 /* Initialize the command buffer */
1813 buffer = (u8 *) malloc(cmd_len);
1815 printf("ERR:Cannot allocate buffer for command!\n");
1818 bzero((char *) buffer, cmd_len);
1820 /* Locate headers */
1821 cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
1822 tlv = (TLVBUF_RATES *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));
1824 /* Fill the command buffer */
1825 cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
1826 cmd_buf->Size = cmd_len;
1827 cmd_buf->SeqNum = 0;
1828 cmd_buf->Result = 0;
1829 tlv->Tag = MRVL_RATES_TLV_ID;
1831 cmd_buf->Action = ACTION_GET;
1832 tlv->Length = MAX_RATES;
1834 cmd_buf->Action = ACTION_SET;
1836 for (i = 0; i < tlv->Length; i++) {
1837 tlv->OperationalRates[i] = (u8) A2HEXDECIMAL(argv[i]);
1841 endian_convert_tlv_header_out(tlv);
1842 /* Send the command */
1843 ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
1844 endian_convert_tlv_header_in(tlv);
1845 /* Process response */
1846 if (ret == UAP_SUCCESS) {
1847 /* Verify response */
1848 if ((cmd_buf->CmdCode != (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) ||
1849 (tlv->Tag != MRVL_RATES_TLV_ID)) {
1850 printf("ERR:Corrupted response! CmdCode=%x, Tlv->Tag=%x\n",
1851 cmd_buf->CmdCode, tlv->Tag);
1856 /* Print response */
1857 if (cmd_buf->Result == CMD_SUCCESS) {
1861 printf("Rates setting successful\n");
1865 printf("ERR:Could not get operational rates!\n");
1867 printf("ERR:Could not set operational rates!\n");
1871 printf("ERR:Command sending failed!\n");
1879 * @brief Creates a sys_cfg request for Tx power
1880 * and sends to the driver
1882 * Usage: "sys_cfg_tx_power [TX_POWER]"
1883 * if TX_POWER is provided, a 'set' is performed
1884 * else a 'get' is performed.
1886 * TX_POWER is represented in dBm
1888 * @param argc Number of arguments
1889 * @param argv Pointer to the arguments
1893 apcmd_sys_cfg_tx_power(int argc, char *argv[])
1895 APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
1896 TLVBUF_TX_POWER *tlv = NULL;
1899 int ret = UAP_FAILURE;
1901 while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
1904 print_sys_cfg_tx_power_usage();
1910 /* Check arguments */
1911 if (argc && is_input_valid(TXPOWER, argc, argv) != UAP_SUCCESS) {
1912 print_sys_cfg_tx_power_usage();
1916 /* Initialize the command length */
1917 cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_TX_POWER);
1919 /* Initialize the command buffer */
1920 buffer = (u8 *) malloc(cmd_len);
1923 printf("ERR:Cannot allocate buffer for command!\n");
1926 bzero((char *) buffer, cmd_len);
1928 /* Locate headers */
1929 cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
1930 tlv = (TLVBUF_TX_POWER *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));
1932 /* Fill the command buffer */
1933 cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
1934 cmd_buf->Size = cmd_len;
1935 cmd_buf->SeqNum = 0;
1936 cmd_buf->Result = 0;
1937 tlv->Tag = MRVL_TX_POWER_TLV_ID;
1940 cmd_buf->Action = ACTION_GET;
1942 printf("Please check power calibration for board to see if this power\n"
1943 "setting is within calibrated range. Firmware may over-ride\n "
1944 "this setting if it is not within calibrated range, which can\n"
1945 "vary from board to board.\n");
1946 cmd_buf->Action = ACTION_SET;
1947 tlv->TxPower_dBm = (u8) atoi(argv[0]);
1949 endian_convert_tlv_header_out(tlv);
1950 /* Send the command */
1951 ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
1952 endian_convert_tlv_header_in(tlv);
1953 /* Process response */
1954 if (ret == UAP_SUCCESS) {
1955 /* Verify response */
1956 if ((cmd_buf->CmdCode != (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) ||
1957 (tlv->Tag != MRVL_TX_POWER_TLV_ID)) {
1958 printf("ERR:Corrupted response! CmdCode=%x, Tlv->Tag=%x\n",
1959 cmd_buf->CmdCode, tlv->Tag);
1963 /* Print response */
1964 if (cmd_buf->Result == CMD_SUCCESS) {
1966 printf("Tx power = %d dBm\n", tlv->TxPower_dBm);
1968 printf("Tx power setting successful\n");
1972 printf("ERR:Could not get tx power!\n");
1974 printf("ERR:Could not set tx power!\n");
1978 printf("ERR:Command sending failed!\n");
1986 * @brief Creates a sys_cfg request for SSID broadcast
1987 * and sends to the driver
1989 * Usage: "sys_cfg_bcast_ssid_ctl [0|1]"
1991 * Options: 0 - Disable SSID broadcast
1992 * 1 - Enable SSID broadcast
1993 * empty - Get current SSID broadcast setting
1995 * @param argc Number of arguments
1996 * @param argv Pointer to the arguments
2000 apcmd_sys_cfg_bcast_ssid_ctl(int argc, char *argv[])
2002 APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
2003 TLVBUF_BCAST_SSID_CTL *tlv = NULL;
2006 int ret = UAP_FAILURE;
2009 while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
2012 print_sys_cfg_bcast_ssid_ctl_usage();
2018 /* Check arguments */
2019 if (argc && is_input_valid(BROADCASTSSID, argc, argv) != UAP_SUCCESS) {
2020 print_sys_cfg_bcast_ssid_ctl_usage();
2023 /* Initialize the command length */
2024 cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_BCAST_SSID_CTL);
2026 /* Initialize the command buffer */
2027 buffer = (u8 *) malloc(cmd_len);
2029 printf("ERR:Cannot allocate buffer for command!\n");
2032 bzero((char *) buffer, cmd_len);
2034 /* Locate headers */
2035 cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
2036 tlv = (TLVBUF_BCAST_SSID_CTL *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));
2038 /* Fill the command buffer */
2039 cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
2040 cmd_buf->Size = cmd_len;
2041 cmd_buf->SeqNum = 0;
2042 cmd_buf->Result = 0;
2043 tlv->Tag = MRVL_BCAST_SSID_CTL_TLV_ID;
2046 cmd_buf->Action = ACTION_GET;
2048 cmd_buf->Action = ACTION_SET;
2049 tlv->BcastSsidCtl = (u8) atoi(argv[0]);
2051 endian_convert_tlv_header_out(tlv);
2052 /* Send the command */
2053 ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
2054 endian_convert_tlv_header_in(tlv);
2055 /* Process response */
2056 if (ret == UAP_SUCCESS) {
2057 /* Verify response */
2058 if ((cmd_buf->CmdCode != (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) ||
2059 (tlv->Tag != MRVL_BCAST_SSID_CTL_TLV_ID)) {
2060 printf("ERR:Corrupted response! CmdCode=%x, Tlv->Tag=%x\n",
2061 cmd_buf->CmdCode, tlv->Tag);
2065 /* Print response */
2066 if (cmd_buf->Result == CMD_SUCCESS) {
2068 printf("SSID broadcast is %s\n",
2069 (tlv->BcastSsidCtl == 1) ? "enabled" : "disabled");
2071 printf("SSID broadcast setting successful\n");
2075 printf("ERR:Could not get SSID broadcast!\n");
2077 printf("ERR:Could not set SSID broadcast!\n");
2081 printf("ERR:Command sending failed!\n");
2089 * @brief Creates a sys_cfg request for preamble settings
2090 * and sends to the driver
2092 * Usage: "sys_cfg_preamble_ctl"
2094 * @param argc Number of arguments
2095 * @param argv Pointer to the arguments
2099 apcmd_sys_cfg_preamble_ctl(int argc, char *argv[])
2101 APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
2102 TLVBUF_PREAMBLE_CTL *tlv = NULL;
2105 int ret = UAP_FAILURE;
2107 while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
2110 print_sys_cfg_preamble_ctl_usage();
2117 /* Check arguments */
2119 printf("ERR:Too many arguments.\n");
2120 print_sys_cfg_preamble_ctl_usage();
2123 /* Initialize the command length */
2124 cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_PREAMBLE_CTL);
2126 /* Initialize the command buffer */
2127 buffer = (u8 *) malloc(cmd_len);
2130 printf("ERR:Cannot allocate buffer for command!\n");
2133 bzero((char *) buffer, cmd_len);
2135 /* Locate headers */
2136 cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
2137 tlv = (TLVBUF_PREAMBLE_CTL *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));
2139 /* Fill the command buffer */
2140 cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
2141 cmd_buf->Size = cmd_len;
2142 cmd_buf->SeqNum = 0;
2143 cmd_buf->Result = 0;
2144 tlv->Tag = MRVL_PREAMBLE_CTL_TLV_ID;
2146 cmd_buf->Action = ACTION_GET;
2147 endian_convert_tlv_header_out(tlv);
2148 /* Send the command */
2149 ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
2150 endian_convert_tlv_header_in(tlv);
2151 /* Process response */
2152 if (ret == UAP_SUCCESS) {
2153 /* Verify response */
2154 if ((cmd_buf->CmdCode != (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) ||
2155 (tlv->Tag != MRVL_PREAMBLE_CTL_TLV_ID)) {
2156 printf("ERR:Corrupted response! CmdCode=%x, Tlv->Tag=%x\n",
2157 cmd_buf->CmdCode, tlv->Tag);
2161 /* Print response */
2162 if (cmd_buf->Result == CMD_SUCCESS)
2163 printf("Preamble type is %s\n", (tlv->PreambleType == 0) ?
2164 "auto" : ((tlv->PreambleType == 1) ? "short" : "long"));
2166 printf("ERR:Could not get preamble type!\n");
2169 printf("ERR:Command sending failed!\n");
2177 * @brief Creates a sys_cfg request for antenna configuration
2178 * and sends to the driver
2180 * Usage: "sys_cfg_antenna_ctl <ANTENNA> [MODE]"
2182 * Options: ANTENNA : 0 - Rx antenna
2184 * MODE : 0 - Antenna A
2186 * empty - Get current antenna settings
2188 * @param argc Number of arguments
2189 * @param argv Pointer to the arguments
2193 apcmd_sys_cfg_antenna_ctl(int argc, char *argv[])
2195 APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
2196 TLVBUF_ANTENNA_CTL *tlv = NULL;
2199 int ret = UAP_FAILURE;
2201 while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
2204 print_sys_cfg_antenna_ctl_usage();
2210 /* Check arguments */
2211 if ((argc == 0) || (argc > 2)) {
2212 printf("ERR:wrong arguments.\n");
2213 print_sys_cfg_antenna_ctl_usage();
2215 } else if (argc == 1) {
2216 if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) < 0) ||
2217 (atoi(argv[0]) > 1)) {
2219 ("ERR:Illegal ANTENNA parameter %s. Must be either '0' or '1'.\n",
2221 print_sys_cfg_antenna_ctl_usage();
2225 if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) < 0) ||
2226 (atoi(argv[0]) > 1)) {
2228 ("ERR:Illegal ANTENNA parameter %s. Must be either '0' or '1'.\n",
2230 print_sys_cfg_antenna_ctl_usage();
2233 if ((ISDIGIT(argv[1]) == 0) || (atoi(argv[1]) < 0) ||
2234 (atoi(argv[1]) > 1)) {
2236 ("ERR:Illegal MODE parameter %s. Must be either '0' or '1'.\n",
2238 print_sys_cfg_antenna_ctl_usage();
2243 /* Initialize the command length */
2244 cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_ANTENNA_CTL);
2246 /* Initialize the command buffer */
2247 buffer = (u8 *) malloc(cmd_len);
2250 printf("ERR:Cannot allocate buffer for command!\n");
2253 bzero((char *) buffer, cmd_len);
2254 /* Locate headers */
2255 cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
2256 tlv = (TLVBUF_ANTENNA_CTL *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));
2258 /* Fill the command buffer */
2259 cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
2260 cmd_buf->Size = cmd_len;
2261 cmd_buf->SeqNum = 0;
2262 cmd_buf->Result = 0;
2263 tlv->Tag = MRVL_ANTENNA_CTL_TLV_ID;
2265 tlv->WhichAntenna = (u8) atoi(argv[0]);
2267 cmd_buf->Action = ACTION_GET;
2269 cmd_buf->Action = ACTION_SET;
2270 tlv->AntennaMode = (u8) atoi(argv[1]);
2272 endian_convert_tlv_header_out(tlv);
2273 /* Send the command */
2274 ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
2275 endian_convert_tlv_header_in(tlv);
2276 /* Process response */
2277 if (ret == UAP_SUCCESS) {
2278 /* Verify response */
2279 if ((cmd_buf->CmdCode != (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) ||
2280 (tlv->Tag != MRVL_ANTENNA_CTL_TLV_ID)) {
2281 printf("ERR:Corrupted response! CmdCode=%x, Tlv->Tag=%x\n",
2282 cmd_buf->CmdCode, tlv->Tag);
2286 /* Print response */
2287 if (cmd_buf->Result == CMD_SUCCESS) {
2289 printf("%s antenna: %s\n", (tlv->WhichAntenna == 0) ?
2290 "Rx" : "Tx", (tlv->AntennaMode == 0) ? "A" : "B");
2292 printf("Antenna setting successful\n");
2296 printf("ERR:Could not get antenna!\n");
2298 printf("ERR:Could not set antenna!\n");
2302 printf("ERR:Command sending failed!\n");
2310 * @brief Creates a sys_cfg request for RTS threshold
2311 * and sends to the driver
2313 * Usage: "sys_cfg_rts_threshold [RTS_THRESHOLD]"
2314 * if RTS_THRESHOLD is provided, a 'set' is performed
2315 * else a 'get' is performed
2317 * @param argc Number of arguments
2318 * @param argv Pointer to the arguments
2322 apcmd_sys_cfg_rts_threshold(int argc, char *argv[])
2324 APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
2325 TLVBUF_RTS_THRESHOLD *tlv = NULL;
2328 int ret = UAP_FAILURE;
2330 while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
2333 print_sys_cfg_rts_threshold_usage();
2339 /* Check arguments */
2340 if (argc && (is_input_valid(RTSTHRESH, argc, argv) != UAP_SUCCESS)) {
2341 print_sys_cfg_rts_threshold_usage();
2344 /* Initialize the command length */
2345 cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_RTS_THRESHOLD);
2347 /* Initialize the command buffer */
2348 buffer = (u8 *) malloc(cmd_len);
2351 printf("ERR:Cannot allocate buffer for command!\n");
2354 bzero((char *) buffer, cmd_len);
2356 /* Locate headers */
2357 cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
2358 tlv = (TLVBUF_RTS_THRESHOLD *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));
2360 /* Fill the command buffer */
2361 cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
2362 cmd_buf->Size = cmd_len;
2363 cmd_buf->SeqNum = 0;
2364 cmd_buf->Result = 0;
2365 tlv->Tag = MRVL_RTS_THRESHOLD_TLV_ID;
2368 cmd_buf->Action = ACTION_GET;
2370 cmd_buf->Action = ACTION_SET;
2371 tlv->RtsThreshold = (u16) atoi(argv[0]);
2373 endian_convert_tlv_header_out(tlv);
2374 tlv->RtsThreshold = uap_cpu_to_le16(tlv->RtsThreshold);
2375 /* Send the command */
2376 ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
2377 endian_convert_tlv_header_in(tlv);
2378 tlv->RtsThreshold = uap_le16_to_cpu(tlv->RtsThreshold);
2379 /* Process response */
2380 if (ret == UAP_SUCCESS) {
2381 /* Verify response */
2382 if ((cmd_buf->CmdCode != (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) ||
2383 (tlv->Tag != MRVL_RTS_THRESHOLD_TLV_ID)) {
2384 printf("ERR:Corrupted response! CmdCode=%x, Tlv->Tag=%x\n",
2385 cmd_buf->CmdCode, tlv->Tag);
2389 /* Print response */
2390 if (cmd_buf->Result == CMD_SUCCESS) {
2392 printf("RTS threshold = %d\n", tlv->RtsThreshold);
2394 printf("RTS threshold setting successful\n");
2398 printf("ERR:Could not get RTS threshold!\n");
2400 printf("ERR:Could not set RTS threshold!\n");
2404 printf("ERR:Command sending failed!\n");
2412 * @brief Creates a sys_cfg request for Fragmentation threshold
2413 * and sends to the driver
2415 * Usage: "sys_cfg_frag_threshold [FRAG_THRESHOLD]"
2416 * if FRAG_THRESHOLD is provided, a 'set' is performed
2417 * else a 'get' is performed
2419 * @param argc Number of arguments
2420 * @param argv Pointer to the arguments
2424 apcmd_sys_cfg_frag_threshold(int argc, char *argv[])
2426 APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
2427 TLVBUF_FRAG_THRESHOLD *tlv = NULL;
2430 int ret = UAP_FAILURE;
2432 while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
2435 print_sys_cfg_frag_threshold_usage();
2441 /* Check arguments */
2442 if (argc && (is_input_valid(FRAGTHRESH, argc, argv) != UAP_SUCCESS)) {
2443 print_sys_cfg_frag_threshold_usage();
2446 /* Initialize the command length */
2447 cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_FRAG_THRESHOLD);
2449 /* Initialize the command buffer */
2450 buffer = (u8 *) malloc(cmd_len);
2453 printf("ERR:Cannot allocate buffer for command!\n");
2456 bzero((char *) buffer, cmd_len);
2458 /* Locate headers */
2459 cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
2460 tlv = (TLVBUF_FRAG_THRESHOLD *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));
2462 /* Fill the command buffer */
2463 cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
2464 cmd_buf->Size = cmd_len;
2465 cmd_buf->SeqNum = 0;
2466 cmd_buf->Result = 0;
2467 tlv->Tag = MRVL_FRAG_THRESHOLD_TLV_ID;
2470 cmd_buf->Action = ACTION_GET;
2472 cmd_buf->Action = ACTION_SET;
2473 tlv->FragThreshold = (u16) atoi(argv[0]);
2475 endian_convert_tlv_header_out(tlv);
2476 tlv->FragThreshold = uap_cpu_to_le16(tlv->FragThreshold);
2477 /* Send the command */
2478 ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
2479 endian_convert_tlv_header_in(tlv);
2480 tlv->FragThreshold = uap_le16_to_cpu(tlv->FragThreshold);
2482 /* Process response */
2483 if (ret == UAP_SUCCESS) {
2484 /* Verify response */
2485 if ((cmd_buf->CmdCode != (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) ||
2486 (tlv->Tag != MRVL_FRAG_THRESHOLD_TLV_ID)) {
2487 printf("ERR:Corrupted response! CmdCode=%x, Tlv->Tag=%x\n",
2488 cmd_buf->CmdCode, tlv->Tag);
2492 /* Print response */
2493 if (cmd_buf->Result == CMD_SUCCESS) {
2495 printf("Fragmentation threshold = %d\n", tlv->FragThreshold);
2497 printf("Fragmentation threshold setting successful\n");
2501 printf("ERR:Could not get Fragmentation threshold!\n");
2503 printf("ERR:Could not set Fragmentation threshold!\n");
2507 printf("ERR:Command sending failed!\n");
2515 * @brief Creates a sys_cfg request for radio settings
2516 * and sends to the driver
2518 * Usage: "sys_cfg_radio_ctl [0|1]"
2520 * Options: 0 - Turn radio on
2521 * 1 - Turn radio off
2522 * empty - Get current radio setting
2524 * @param argc Number of arguments
2525 * @param argv Pointer to the arguments
2529 apcmd_sys_cfg_radio_ctl(int argc, char *argv[])
2531 APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
2532 TLVBUF_RADIO_CTL *tlv = NULL;
2535 int ret = UAP_FAILURE;
2537 while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
2540 print_sys_cfg_radio_ctl_usage();
2546 /* Check arguments */
2547 if (argc && (is_input_valid(RADIOCONTROL, argc, argv) != UAP_SUCCESS)) {
2548 print_sys_cfg_radio_ctl_usage();
2551 /* Initialize the command length */
2552 cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_RADIO_CTL);
2554 /* Initialize the command buffer */
2555 buffer = (u8 *) malloc(cmd_len);
2557 printf("ERR:Cannot allocate buffer for command!\n");
2560 bzero((char *) buffer, cmd_len);
2562 /* Locate headers */
2563 cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
2564 tlv = (TLVBUF_RADIO_CTL *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));
2566 /* Fill the command buffer */
2567 cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
2568 cmd_buf->Size = cmd_len;
2569 cmd_buf->SeqNum = 0;
2570 cmd_buf->Result = 0;
2571 tlv->Tag = MRVL_RADIO_CTL_TLV_ID;
2574 cmd_buf->Action = ACTION_GET;
2576 cmd_buf->Action = ACTION_SET;
2577 tlv->RadioCtl = (u8) atoi(argv[0]);
2579 endian_convert_tlv_header_out(tlv);
2580 /* Send the command */
2581 ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
2582 endian_convert_tlv_header_in(tlv);
2583 /* Process response */
2584 if (ret == UAP_SUCCESS) {
2585 /* Verify response */
2586 if ((cmd_buf->CmdCode != (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) ||
2587 (tlv->Tag != MRVL_RADIO_CTL_TLV_ID)) {
2588 printf("ERR:Corrupted response! CmdCode=%x, Tlv->Tag=%x\n",
2589 cmd_buf->CmdCode, tlv->Tag);
2593 /* Print response */
2594 if (cmd_buf->Result == CMD_SUCCESS) {
2596 printf("Radio is %s\n", (tlv->RadioCtl == 0) ? "on" : "off");
2598 printf("Radio setting successful\n");
2602 printf("ERR:Could not get radio status!\n");
2604 printf("ERR:Could not set radio status!\n");
2608 printf("ERR:Command sending failed!\n");
2616 * @brief Creates a sys_cfg request for RSN replay protection
2617 * and sends to the driver
2619 * Usage: "sys_cfg_rsn_replay_prot [0|1]"
2621 * Options: 0 - Disable RSN replay protection
2622 * 1 - Enable RSN replay protection
2623 * empty - Get current RSN replay protection setting
2625 * @param argc Number of arguments
2626 * @param argv Pointer to the arguments
2630 apcmd_sys_cfg_rsn_replay_prot(int argc, char *argv[])
2632 APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
2633 tlvbuf_rsn_replay_prot *tlv = NULL;
2636 int ret = UAP_FAILURE;
2639 while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
2642 print_sys_cfg_rsn_replay_prot_usage();
2648 /* Check arguments */
2649 if (argc && is_input_valid(RSNREPLAYPROT, argc, argv) != UAP_SUCCESS) {
2650 print_sys_cfg_rsn_replay_prot_usage();
2653 /* Initialize the command length */
2654 cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(tlvbuf_rsn_replay_prot);
2656 /* Initialize the command buffer */
2657 buffer = (u8 *) malloc(cmd_len);
2659 printf("ERR:Cannot allocate buffer for command!\n");
2662 bzero((char *) buffer, cmd_len);
2664 /* Locate headers */
2665 cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
2666 tlv = (tlvbuf_rsn_replay_prot *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));
2668 /* Fill the command buffer */
2669 cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
2670 cmd_buf->Size = cmd_len;
2671 cmd_buf->SeqNum = 0;
2672 cmd_buf->Result = 0;
2673 tlv->Tag = MRVL_RSN_REPLAY_PROT_TLV_ID;
2676 cmd_buf->Action = ACTION_GET;
2678 cmd_buf->Action = ACTION_SET;
2679 tlv->rsn_replay_prot = (u8) atoi(argv[0]);
2681 endian_convert_tlv_header_out(tlv);
2682 /* Send the command */
2683 ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
2684 endian_convert_tlv_header_in(tlv);
2685 /* Process response */
2686 if (ret == UAP_SUCCESS) {
2687 /* Verify response */
2688 if ((cmd_buf->CmdCode != (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) ||
2689 (tlv->Tag != MRVL_RSN_REPLAY_PROT_TLV_ID)) {
2690 printf("ERR:Corrupted response! CmdCode=%x, Tlv->Tag=%x\n",
2691 cmd_buf->CmdCode, tlv->Tag);
2695 /* Print response */
2696 if (cmd_buf->Result == CMD_SUCCESS) {
2698 printf("RSN replay protection is %s\n",
2699 (tlv->rsn_replay_prot == 1) ? "enabled" : "disabled");
2701 printf("RSN replay protection setting successful\n");
2705 printf("ERR:Could not get RSN replay protection !\n");
2707 printf("ERR:Could not set RSN replay protection !\n");
2711 printf("ERR:Command sending failed!\n");
2719 * @brief Creates a sys_cfg request for MCBC data rates
2720 * and sends to the driver
2722 * Usage: "sys_cfg_mcbc_data_rate [MCBC_DATA_RATE]"
2724 * Options: 0 - Auto rate
2725 * >0 - Set specified MCBC data rate
2726 * empty - Get current MCBC data rate
2728 * MCBC_DATA_RATE is represented in units of 500 kbps
2730 * @param argc Number of arguments
2731 * @param argv Pointer to the arguments
2735 apcmd_sys_cfg_mcbc_data_rate(int argc, char *argv[])
2737 APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
2738 TLVBUF_MCBC_DATA_RATE *tlv = NULL;
2741 int ret = UAP_FAILURE;
2743 while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
2746 print_sys_cfg_mcbc_data_rates_usage();
2753 /* Check arguments */
2755 if (is_input_valid(MCBCDATARATE, argc, argv) != UAP_SUCCESS) {
2756 printf("ERR: Invalid input\n");
2757 print_sys_cfg_mcbc_data_rates_usage();
2760 if ((A2HEXDECIMAL(argv[0]) != 0) &&
2761 (is_mcbc_rate_valid(A2HEXDECIMAL(argv[0])) != UAP_SUCCESS)) {
2762 printf("ERR: invalid MCBC data rate.");
2763 print_sys_cfg_mcbc_data_rates_usage();
2768 /* Initialize the command length */
2769 cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_MCBC_DATA_RATE);
2771 /* Initialize the command buffer */
2772 buffer = (u8 *) malloc(cmd_len);
2775 printf("ERR:Cannot allocate buffer for command!\n");
2778 bzero((char *) buffer, cmd_len);
2780 /* Locate headers */
2781 cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
2782 tlv = (TLVBUF_MCBC_DATA_RATE *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));
2784 /* Fill the command buffer */
2785 cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
2786 cmd_buf->Size = cmd_len;
2787 cmd_buf->SeqNum = 0;
2788 cmd_buf->Result = 0;
2789 tlv->Tag = MRVL_MCBC_DATA_RATE_TLV_ID;
2792 cmd_buf->Action = ACTION_GET;
2794 cmd_buf->Action = ACTION_SET;
2795 tlv->MCBCdatarate = (u16) A2HEXDECIMAL(argv[0]);
2797 endian_convert_tlv_header_out(tlv);
2798 tlv->MCBCdatarate = uap_cpu_to_le16(tlv->MCBCdatarate);
2800 /* Send the command */
2801 ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
2802 endian_convert_tlv_header_in(tlv);
2803 tlv->MCBCdatarate = uap_le16_to_cpu(tlv->MCBCdatarate);
2805 /* Process response */
2806 if (ret == UAP_SUCCESS) {
2807 /* Verify response */
2808 if ((cmd_buf->CmdCode != (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) ||
2809 (tlv->Tag != MRVL_MCBC_DATA_RATE_TLV_ID)) {
2810 printf("ERR:Corrupted response! CmdCode=%x, Tlv->Tag=%x\n",
2811 cmd_buf->CmdCode, tlv->Tag);
2815 /* Print response */
2816 if (cmd_buf->Result == CMD_SUCCESS) {
2818 if (tlv->MCBCdatarate == 0) {
2819 printf("MCBC data rate is auto\n");
2821 printf("MCBC data rate = 0x%x\n", tlv->MCBCdatarate);
2824 printf("MCBC data rate setting successful\n");
2828 printf("ERR:Could not get MCBC data rate!\n");
2830 printf("ERR:Could not set MCBC data rate!\n");
2834 printf("ERR:Command sending failed!\n");
2842 * @brief Creates a sys_cfg request for Tx data rates
2843 * and sends to the driver
2845 * Usage: "sys_cfg_tx_data_rate [TX_DATA_RATE]"
2847 * Options: 0 - Auto rate
2848 * >0 - Set specified data rate
2849 * empty - Get current data rate
2851 * TX_DATA_RATE is represented in units of 500 kbps
2853 * @param argc Number of arguments
2854 * @param argv Pointer to the arguments
2858 apcmd_sys_cfg_tx_data_rate(int argc, char *argv[])
2860 APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
2861 TLVBUF_TX_DATA_RATE *tlv = NULL;
2864 int ret = UAP_FAILURE;
2866 while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
2869 print_sys_cfg_tx_data_rates_usage();
2876 /* Check arguments */
2878 if (is_input_valid(TXDATARATE, argc, argv) != UAP_SUCCESS) {
2879 printf("ERR: Invalid input\n");
2880 print_sys_cfg_tx_data_rates_usage();
2882 } else if ((A2HEXDECIMAL(argv[0]) != 0) &&
2883 (is_tx_rate_valid(A2HEXDECIMAL(argv[0])) != UAP_SUCCESS)) {
2884 printf("ERR: invalid tx data rate.");
2885 print_sys_cfg_tx_data_rates_usage();
2890 /* Initialize the command length */
2891 cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_TX_DATA_RATE);
2893 /* Initialize the command buffer */
2894 buffer = (u8 *) malloc(cmd_len);
2897 printf("ERR:Cannot allocate buffer for command!\n");
2900 bzero((char *) buffer, cmd_len);
2902 /* Locate headers */
2903 cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
2904 tlv = (TLVBUF_TX_DATA_RATE *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));
2906 /* Fill the command buffer */
2907 cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
2908 cmd_buf->Size = cmd_len;
2909 cmd_buf->SeqNum = 0;
2910 cmd_buf->Result = 0;
2911 tlv->Tag = MRVL_TX_DATA_RATE_TLV_ID;
2914 cmd_buf->Action = ACTION_GET;
2916 cmd_buf->Action = ACTION_SET;
2917 tlv->TxDataRate = (u16) A2HEXDECIMAL(argv[0]);
2919 endian_convert_tlv_header_out(tlv);
2920 tlv->TxDataRate = uap_cpu_to_le16(tlv->TxDataRate);
2922 /* Send the command */
2923 ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
2924 endian_convert_tlv_header_in(tlv);
2925 tlv->TxDataRate = uap_le16_to_cpu(tlv->TxDataRate);
2927 /* Process response */
2928 if (ret == UAP_SUCCESS) {
2929 /* Verify response */
2930 if ((cmd_buf->CmdCode != (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) ||
2931 (tlv->Tag != MRVL_TX_DATA_RATE_TLV_ID)) {
2932 printf("ERR:Corrupted response! CmdCode=%x, Tlv->Tag=%x\n",
2933 cmd_buf->CmdCode, tlv->Tag);
2937 /* Print response */
2938 if (cmd_buf->Result == CMD_SUCCESS) {
2940 if (tlv->TxDataRate == 0) {
2941 printf("Tx data rate is auto\n");
2943 printf("Tx data rate = 0x%x\n", tlv->TxDataRate);
2946 printf("Tx data rate setting successful\n");
2950 printf("ERR:Could not get tx data rate!\n");
2952 printf("ERR:Could not set tx data rate!\n");
2956 printf("ERR:Command sending failed!\n");
2964 * @brief Creates a sys_cfg request for packet forwarding
2965 * and sends to the driver
2967 * Usage: "sys_cfg_pkt_fwd_ctl [0|1]"
2969 * Options: 0 - Forward all packets to the host
2970 * 1 - Firmware handles intra-BSS packets
2971 * empty - Get current packet forwarding setting
2973 * @param argc Number of arguments
2974 * @param argv Pointer to the arguments
2978 apcmd_sys_cfg_pkt_fwd_ctl(int argc, char *argv[])
2980 APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
2981 TLVBUF_PKT_FWD_CTL *tlv = NULL;
2984 int ret = UAP_FAILURE;
2986 while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
2989 print_sys_cfg_pkt_fwd_ctl_usage();
2995 /* Check arguments */
2996 if (argc && (is_input_valid(PKTFWD, argc, argv) != UAP_SUCCESS)) {
2997 print_sys_cfg_pkt_fwd_ctl_usage();
3000 /* Initialize the command length */
3001 cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_PKT_FWD_CTL);
3002 /* Initialize the command buffer */
3003 buffer = (u8 *) malloc(cmd_len);
3006 printf("ERR:Cannot allocate buffer for command!\n");
3009 bzero((char *) buffer, cmd_len);
3011 /* Locate headers */
3012 cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
3013 tlv = (TLVBUF_PKT_FWD_CTL *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));
3015 /* Fill the command buffer */
3016 cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
3017 cmd_buf->Size = cmd_len;
3018 cmd_buf->SeqNum = 0;
3019 cmd_buf->Result = 0;
3020 tlv->Tag = MRVL_PKT_FWD_CTL_TLV_ID;
3023 cmd_buf->Action = ACTION_GET;
3025 cmd_buf->Action = ACTION_SET;
3026 tlv->PktFwdCtl = (u8) atoi(argv[0]);
3028 endian_convert_tlv_header_out(tlv);
3029 /* Send the command */
3030 ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
3031 endian_convert_tlv_header_in(tlv);
3032 /* Process response */
3033 if (ret == UAP_SUCCESS) {
3034 /* Verify response */
3035 if ((cmd_buf->CmdCode != (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) ||
3036 (tlv->Tag != MRVL_PKT_FWD_CTL_TLV_ID)) {
3037 printf("ERR:Corrupted response! CmdCode=%x, Tlv->Tag=%x\n",
3038 cmd_buf->CmdCode, tlv->Tag);
3042 /* Print response */
3043 if (cmd_buf->Result == CMD_SUCCESS) {
3045 printf("Firmware %s\n", (tlv->PktFwdCtl == 0) ?
3046 "forwards all packets to the host" :
3047 "handles intra-BSS packets");
3049 printf("Packet control logic setting successful\n");
3053 printf("ERR:Could not get packet control logic!\n");
3055 printf("ERR:Could not set packet control logic!\n");
3059 printf("ERR:Command sending failed!\n");
3067 * @brief Creates a sys_cfg request for STA ageout timer
3068 * and sends to the driver
3070 * Usage: "sys_cfg_sta_ageout_timer [STA_AGEOUT_TIMER]"
3071 * if STA_AGEOUT_TIMER is provided, a 'set' is performed
3072 * else a 'get' is performed.
3073 * The value should between 300 and 864000
3075 * STA_AGEOUT_TIMER is represented in units of 100 ms
3077 * @param argc Number of arguments
3078 * @param argv Pointer to the arguments
3082 apcmd_sys_cfg_sta_ageout_timer(int argc, char *argv[])
3084 APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
3085 TLVBUF_STA_AGEOUT_TIMER *tlv = NULL;
3088 int ret = UAP_FAILURE;
3090 while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
3093 print_sys_cfg_sta_ageout_timer_usage();
3099 /* Check arguments */
3100 if (argc && (is_input_valid(STAAGEOUTTIMER, argc, argv) != UAP_SUCCESS)) {
3101 print_sys_cfg_sta_ageout_timer_usage();
3104 /* Initialize the command length */
3105 cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_STA_AGEOUT_TIMER);
3107 /* Initialize the command buffer */
3108 buffer = (u8 *) malloc(cmd_len);
3111 printf("ERR:Cannot allocate buffer for command!\n");
3114 bzero((char *) buffer, cmd_len);
3116 /* Locate headers */
3117 cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
3118 tlv = (TLVBUF_STA_AGEOUT_TIMER *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));
3120 /* Fill the command buffer */
3121 cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
3122 cmd_buf->Size = cmd_len;
3123 cmd_buf->SeqNum = 0;
3124 cmd_buf->Result = 0;
3125 tlv->Tag = MRVL_STA_AGEOUT_TIMER_TLV_ID;
3128 cmd_buf->Action = ACTION_GET;
3130 cmd_buf->Action = ACTION_SET;
3131 tlv->StaAgeoutTimer_ms = (u32) atoi(argv[0]);
3133 endian_convert_tlv_header_out(tlv);
3134 tlv->StaAgeoutTimer_ms = uap_cpu_to_le32(tlv->StaAgeoutTimer_ms);
3135 /* Send the command */
3136 ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
3137 endian_convert_tlv_header_in(tlv);
3138 tlv->StaAgeoutTimer_ms = uap_le32_to_cpu(tlv->StaAgeoutTimer_ms);
3139 /* Process response */
3140 if (ret == UAP_SUCCESS) {
3141 /* Verify response */
3142 if ((cmd_buf->CmdCode != (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) ||
3143 (tlv->Tag != MRVL_STA_AGEOUT_TIMER_TLV_ID)) {
3144 printf("ERR:Corrupted response! CmdCode=%x, Tlv->Tag=%x\n",
3145 cmd_buf->CmdCode, tlv->Tag);
3149 /* Print response */
3150 if (cmd_buf->Result == CMD_SUCCESS) {
3152 printf("STA ageout timer value = %d\n",
3153 (int) tlv->StaAgeoutTimer_ms);
3155 printf("STA ageout timer setting successful\n");
3159 printf("ERR:Could not get STA ageout timer!\n");
3161 printf("ERR:Could not set STA ageout timer!\n");
3165 printf("ERR:Command sending failed!\n");
3173 * @brief Creates a sys_cfg request for authentication mode
3174 * and sends to the driver
3176 * Usage: "Usage : sys_cfg_auth [AUTHMODE]"
3178 * Options: AUTHMODE : 0 - Open authentication
3179 * 1 - Shared key authentication
3180 * empty - Get current authentication mode
3182 * @param argc Number of arguments
3183 * @param argv Pointer to the arguments
3187 apcmd_sys_cfg_auth(int argc, char *argv[])
3189 APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
3190 TLVBUF_AUTH_MODE *tlv = NULL;
3193 int ret = UAP_FAILURE;
3195 while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
3198 print_sys_cfg_auth_usage();
3204 /* Check arguments */
3205 if (argc && (is_input_valid(AUTHMODE, argc, argv) != UAP_SUCCESS)) {
3206 print_sys_cfg_auth_usage();
3209 /* Initialize the command length */
3210 cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_AUTH_MODE);
3212 /* Initialize the command buffer */
3213 buffer = (u8 *) malloc(cmd_len);
3216 printf("ERR:Cannot allocate buffer for command!\n");
3219 bzero((char *) buffer, cmd_len);
3221 /* Locate headers */
3222 cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
3223 tlv = (TLVBUF_AUTH_MODE *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));
3225 /* Fill the command buffer */
3226 cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
3227 cmd_buf->Size = cmd_len;
3228 cmd_buf->SeqNum = 0;
3229 cmd_buf->Result = 0;
3230 tlv->Tag = MRVL_AUTH_TLV_ID;
3233 cmd_buf->Action = ACTION_GET;
3235 cmd_buf->Action = ACTION_SET;
3236 tlv->AuthMode = (u8) atoi(argv[0]);
3238 endian_convert_tlv_header_out(tlv);
3239 /* Send the command */
3240 ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
3241 endian_convert_tlv_header_in(tlv);
3243 /* Process response */
3244 if (ret == UAP_SUCCESS) {
3245 /* Verify response */
3246 if ((cmd_buf->CmdCode != (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) ||
3247 (tlv->Tag != MRVL_AUTH_TLV_ID)) {
3248 printf("ERR:Corrupted response! CmdCode=%x, Tlv->Tag=%x\n",
3249 cmd_buf->CmdCode, tlv->Tag);
3253 /* Print response */
3254 if (cmd_buf->Result == CMD_SUCCESS) {
3258 printf("authentication mode setting successful\n");
3262 printf("ERR:Could not get authentication mode!\n");
3264 printf("ERR:Could not set authentication mode!\n");
3268 printf("ERR:Command sending failed!\n");
3276 * @brief Creates a sys_cfg request for encryption protocol
3277 * and sends to the driver
3279 * Usage: "Usage : sys_cfg_protocol [PROTOCOL]"
3281 * Options: PROTOCOL Bit 0 - No RSN
3282 * Bit 1 - WEP Static
3285 * empty - Get current protocol
3287 * @param argc Number of arguments
3288 * @param argv Pointer to the arguments
3292 apcmd_sys_cfg_protocol(int argc, char *argv[])
3294 APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
3295 TLVBUF_PROTOCOL *tlv = NULL;
3296 TLVBUF_AKMP *akmp_tlv = NULL;
3299 int ret = UAP_FAILURE;
3301 while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
3304 print_sys_cfg_protocol_usage();
3310 /* Check arguments */
3311 if (argc && is_input_valid(PROTOCOL, argc, argv) != UAP_SUCCESS) {
3312 print_sys_cfg_protocol_usage();
3315 /* Initialize the command length */
3317 ((atoi(argv[0]) == PROTOCOL_NO_SECURITY) ||
3318 (atoi(argv[0]) == PROTOCOL_STATIC_WEP))) {
3319 cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_PROTOCOL);
3322 sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_PROTOCOL) +
3323 sizeof(TLVBUF_AKMP);
3324 /* Initialize the command buffer */
3325 buffer = (u8 *) malloc(cmd_len);
3327 printf("ERR:Cannot allocate buffer for command!\n");
3330 bzero((char *) buffer, cmd_len);
3331 /* Locate headers */
3332 cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
3333 tlv = (TLVBUF_PROTOCOL *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));
3335 (TLVBUF_AKMP *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE) +
3336 sizeof(TLVBUF_PROTOCOL));
3337 /* Fill the command buffer */
3338 cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
3339 cmd_buf->Size = cmd_len;
3340 cmd_buf->SeqNum = 0;
3341 cmd_buf->Result = 0;
3342 tlv->Tag = MRVL_PROTOCOL_TLV_ID;
3345 cmd_buf->Action = ACTION_GET;
3346 akmp_tlv->Tag = MRVL_AKMP_TLV_ID;
3347 akmp_tlv->Length = 2;
3349 cmd_buf->Action = ACTION_SET;
3350 tlv->Protocol = (u16) atoi(argv[0]);
3351 if (tlv->Protocol & (PROTOCOL_WPA | PROTOCOL_WPA2)) {
3352 akmp_tlv->Tag = MRVL_AKMP_TLV_ID;
3353 akmp_tlv->Length = 2;
3354 akmp_tlv->KeyMgmt = KEY_MGMT_PSK;
3355 akmp_tlv->KeyMgmt = uap_cpu_to_le16(akmp_tlv->KeyMgmt);
3358 endian_convert_tlv_header_out(tlv);
3360 (sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_PROTOCOL) +
3361 sizeof(TLVBUF_AKMP)))
3362 endian_convert_tlv_header_out(akmp_tlv);
3363 tlv->Protocol = uap_cpu_to_le16(tlv->Protocol);
3364 /* Send the command */
3365 ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
3366 endian_convert_tlv_header_in(tlv);
3368 (sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_PROTOCOL) +
3369 sizeof(TLVBUF_AKMP)))
3370 endian_convert_tlv_header_in(akmp_tlv);
3372 /* Process response */
3373 if (ret == UAP_SUCCESS) {
3374 /* Verify response */
3375 if (cmd_buf->CmdCode != (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) {
3376 printf("ERR:Corrupted response! CmdCode=%x, Tlv->Tag=%x\n",
3377 cmd_buf->CmdCode, tlv->Tag);
3381 /* Print response */
3382 if (cmd_buf->Result == CMD_SUCCESS) {
3384 print_tlv((u8 *) tlv,
3385 cmd_buf->Size - sizeof(APCMDBUF_SYS_CONFIGURE) +
3388 printf("protocol setting successful\n");
3392 printf("ERR:Could not get protocol!\n");
3394 printf("ERR:Could not set protocol!\n");
3398 printf("ERR:Command sending failed!\n");
3406 * @brief Creates a sys_cfg request for WEP keys settings
3407 * and sends to the driver
3409 * Usage: "sys_cfg_wep_key [INDEX_0 IS_DEFAULT KEY_0] [INDEX_1 IS_DEFAULT KEY_1] [INDEX_2 IS_DEFAULT KEY_2] [INDEX_3 IS_DEFAULT KEY_3]"
3411 * Options: INDEX_* : 0 - KeyIndex is 0
3415 * IS_DEFAUL : 0 - KeyIndex is not the default
3416 * 1 - KeyIndex is the default transmit key
3418 * empty - Get current WEP key settings
3420 * @param argc Number of arguments
3421 * @param argv Pointer to the arguments
3425 apcmd_sys_cfg_wep_key(int argc, char *argv[])
3427 APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
3428 TLVBUF_WEP_KEY *tlv = NULL;
3432 int ret = UAP_FAILURE;
3435 int number_of_keys = 0;
3438 int is_default = -1;
3441 while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
3444 print_sys_cfg_wep_key_usage();
3451 /* Check arguments */
3453 printf("ERR:Too many arguments.\n");
3454 print_sys_cfg_wep_key_usage();
3456 } else if ((argc > 1) && ((argc % 3) != 0)) {
3457 printf("ERR:Illegal number of parameters.\n");
3458 print_sys_cfg_wep_key_usage();
3460 } else if (argc > 1) {
3461 /* Find number of keys provided */
3462 number_of_keys = argc / 3;
3463 for (i = 0; i < number_of_keys; i++) {
3464 if ((ISDIGIT(argv[(3 * i)]) == 0) || (atoi(argv[(3 * i)]) < 0) ||
3465 (atoi(argv[(3 * i)]) > 3)) {
3467 ("ERR:Illegal INDEX %s. Must be either '0', '1', '2', or '3'.\n",
3469 print_sys_cfg_wep_key_usage();
3472 if ((ISDIGIT(argv[(3 * i) + 1]) == 0) ||
3473 (atoi(argv[(3 * i) + 1]) < 0) ||
3474 (atoi(argv[(3 * i) + 1]) > 1)) {
3476 ("ERR:Illegal IS_DEFAULT %s. Must be either '0', or '1'.\n",
3478 print_sys_cfg_wep_key_usage();
3481 if ((strlen(argv[(3 * i) + 2]) != 5) &&
3482 (strlen(argv[(3 * i) + 2]) != 10)
3483 && (strlen(argv[(3 * i) + 2]) != 13) &&
3484 (strlen(argv[(3 * i) + 2]) != 26)) {
3485 printf("ERR:Incorrect KEY_%d length %d\n", atoi(argv[(3 * i)]),
3486 strlen(argv[(3 * i) + 2]));
3487 print_sys_cfg_wep_key_usage();
3490 if ((strlen(argv[(3 * i) + 2]) == 10) ||
3491 (strlen(argv[(3 * i) + 2]) == 26)) {
3492 if (UAP_FAILURE == ishexstring(argv[(3 * i) + 2])) {
3494 ("ERR:Only hex digits are allowed when key length is 10 or 26\n");
3495 print_sys_cfg_wep_key_usage();
3500 } else if (argc == 1) {
3501 if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) < 0) ||
3502 (atoi(argv[0]) > 3)) {
3504 ("ERR:Illegal INDEX %s. Must be either '0', '1', '2', or '3'.\n",
3506 print_sys_cfg_wep_key_usage();
3511 /* Initialize the command length */
3512 if (argc == 0 || argc == 1) {
3514 cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_HEADER);
3517 sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_WEP_KEY) - 1;
3518 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER;
3520 buf_len = cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE);
3522 /* Initialize the command buffer */
3523 buffer = (u8 *) malloc(buf_len);
3525 printf("ERR:Cannot allocate buffer for command!\n");
3528 bzero((char *) buffer, buf_len);
3529 /* Locate headers */
3530 cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
3532 /* Fill the command buffer */
3533 cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
3534 cmd_buf->SeqNum = 0;
3535 cmd_buf->Result = 0;
3536 if (argc == 0 || argc == 1) {
3537 cmd_buf->Action = ACTION_GET;
3538 tlv = (TLVBUF_WEP_KEY *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));
3539 tlv->Tag = MRVL_WEP_KEY_TLV_ID;
3544 tlv->KeyIndex = atoi(argv[0]);
3546 endian_convert_tlv_header_out(tlv);
3548 cmd_buf->Action = ACTION_SET;
3551 for (i = 0; i < number_of_keys; i++) {
3552 keyindex = atoi(argv[(3 * i)]);
3553 is_default = atoi(argv[(3 * i) + 1]);
3554 key = argv[(3 * i) + 2];
3555 length = strlen(key);
3569 /* Adjust command buffer */
3570 buffer = realloc(buffer, (cmd_len + sizeof(TLVBUF_WEP_KEY) + key_len));
3572 printf("ERR:Cannot append WEP key configurations TLV!\n");
3575 /* Locate headers */
3576 cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
3577 tlv = (TLVBUF_WEP_KEY *) (buffer + cmd_len);
3578 /* Adjust command length */
3579 cmd_len += (sizeof(TLVBUF_WEP_KEY) + key_len);
3580 /* Set TLV fields */
3581 tlv->Tag = MRVL_WEP_KEY_TLV_ID;
3582 tlv->Length = 2 + key_len;
3583 tlv->KeyIndex = (u8) keyindex;
3584 tlv->IsDefault = (u8) is_default;
3585 /* Check if string or raw */
3589 memcpy(tlv->Key, key, length);
3593 string2raw(key, tlv->Key);
3598 endian_convert_tlv_header_out(tlv);
3601 /* Update command length */
3602 cmd_buf->Size = cmd_len;
3603 if ((argc != 0) && (argc != 1))
3606 /* Send the command */
3607 ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, buf_len);
3608 /* Process response */
3609 if (ret == UAP_SUCCESS) {
3610 /* Verify response */
3611 if (cmd_buf->CmdCode != (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) {
3612 printf("ERR:Corrupted response!\n");
3616 /* Print response */
3617 if (cmd_buf->Result == CMD_SUCCESS) {
3618 if ((argc != 0) && (argc != 1)) {
3619 printf("WEP key setting successful\n");
3621 printf("query WEP key setting successful\n");
3623 (TLVBUF_WEP_KEY *) (buffer +
3624 sizeof(APCMDBUF_SYS_CONFIGURE));
3625 print_tlv((u8 *) tlv,
3626 cmd_buf->Size - sizeof(APCMDBUF_SYS_CONFIGURE) +
3630 if ((argc != 0) && (argc != 1))
3631 printf("ERR:Could not set WEP keys!\n");
3633 printf("ERR:Could not get WEP keys!\n");
3636 printf("ERR:Command sending failed!\n");
3644 * @brief Creates a sys_cfg request for custom IE settings
3645 * and sends to the driver
3647 * Usage: "sys_cfg_custom_ie [INDEX] [MASK] [IEBuffer]"
3649 * Options: INDEX : 0 - Get/Set IE index 0 setting
3650 * 1 - Get/Set IE index 1 setting
3651 * 2 - Get/Set IE index 2 setting
3652 * 3 - Get/Set IE index 3 setting
3653 * MASK : Management subtype mask value
3654 * IEBuffer: IE Buffer in hex
3655 * empty - Get all IE settings
3657 * @param argc Number of arguments
3658 * @param argv Pointer to the arguments
3662 apcmd_sys_cfg_custom_ie(int argc, char *argv[])
3664 APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
3665 tlvbuf_custom_ie *tlv = NULL;
3666 custom_ie *ie_ptr = NULL;
3670 u16 mgmt_subtype_mask = 0;
3671 int ret = UAP_FAILURE;
3672 int ie_buf_len = 0, ie_len = 0;
3674 while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
3677 print_sys_cfg_custom_ie_usage();
3684 /* Check arguments */
3686 printf("ERR:Too many arguments.\n");
3687 print_sys_cfg_custom_ie_usage();
3691 /* Error checks and initialize the command length */
3693 if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) < 0) ||
3694 (atoi(argv[0]) > 3)) {
3696 ("ERR:Illegal index %s. Must be either '0', '1', '2', or '3'.\n",
3698 print_sys_cfg_custom_ie_usage();
3704 cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(tlvbuf_custom_ie);
3705 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER;
3708 /* TLV header + ie_index */
3709 cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(tlvbuf_custom_ie) +
3711 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER;
3714 if (UAP_FAILURE == ishexstring(argv[1]) || A2HEXDECIMAL(argv[1]) != 0) {
3715 printf("ERR: Mask value should be 0 to clear IEBuffers.\n");
3716 print_sys_cfg_custom_ie_usage();
3719 buf_len = cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE) +
3720 sizeof(tlvbuf_custom_ie) + sizeof(custom_ie);
3723 if (UAP_FAILURE == ishexstring(argv[1]) || A2HEXDECIMAL(argv[1]) == 0) {
3724 printf("ERR: Mask value should not be 0 to set IEBuffers.\n");
3725 print_sys_cfg_custom_ie_usage();
3728 if (UAP_FAILURE == ishexstring(argv[2])) {
3729 printf("ERR:Only hex digits are allowed\n");
3730 print_sys_cfg_custom_ie_usage();
3733 ie_buf_len = strlen(argv[2]);
3734 if (!strncasecmp("0x", argv[2], 2)) {
3735 ie_len = (ie_buf_len - 2 + 1) / 2;
3738 ie_len = (ie_buf_len + 1) / 2;
3739 if (ie_len > MAX_IE_BUFFER_LEN) {
3740 printf("ERR:Incorrect IE length %d\n", ie_buf_len);
3741 print_sys_cfg_custom_ie_usage();
3744 mgmt_subtype_mask = (u16) A2HEXDECIMAL(argv[1]);
3745 buf_len = cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE) +
3746 sizeof(tlvbuf_custom_ie) + sizeof(custom_ie) + ie_len;
3750 /* Initialize the command buffer */
3751 buffer = (u8 *) malloc(buf_len);
3753 printf("ERR:Cannot allocate buffer for command!\n");
3756 memset(buffer, 0, buf_len);
3757 /* Locate headers */
3758 cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
3760 /* Fill the command buffer */
3761 cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
3762 cmd_buf->SeqNum = 0;
3763 cmd_buf->Result = 0;
3764 cmd_buf->Size = cmd_len;
3766 if (argc == 0 || argc == 1) {
3767 cmd_buf->Action = ACTION_GET;
3768 tlv = (tlvbuf_custom_ie *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));
3769 tlv->Tag = MRVL_MGMT_IE_LIST_TLV_ID;
3773 tlv->Length = sizeof(u16);
3774 ie_ptr = (custom_ie *) (tlv->ie_data);
3775 ie_ptr->ie_index = (u16) uap_cpu_to_le16(atoi(argv[0]));
3777 endian_convert_tlv_header_out(tlv);
3779 cmd_buf->Action = ACTION_SET;
3780 /* Locate headers */
3781 tlv = (tlvbuf_custom_ie *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));
3782 ie_ptr = (custom_ie *) (tlv->ie_data);
3783 /* Set TLV fields */
3784 tlv->Tag = MRVL_MGMT_IE_LIST_TLV_ID;
3785 tlv->Length = sizeof(custom_ie) + ie_len;
3786 ie_ptr->ie_index = uap_cpu_to_le16(atoi(argv[0]));
3787 ie_ptr->mgmt_subtype_mask = uap_cpu_to_le16(mgmt_subtype_mask);
3788 ie_ptr->ie_length = uap_cpu_to_le16(ie_len);
3790 string2raw(argv[2], ie_ptr->ie_buffer);
3791 endian_convert_tlv_header_out(tlv);
3794 /* Send the command */
3795 ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, buf_len);
3796 /* Process response */
3797 if (ret == UAP_SUCCESS) {
3798 /* Verify response */
3799 if (cmd_buf->CmdCode != (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) {
3800 printf("ERR:Corrupted response!\n");
3804 /* Print response */
3805 if (cmd_buf->Result == CMD_SUCCESS) {
3806 if ((argc != 0) && (argc != 1)) {
3807 printf("custom IE setting successful\n");
3809 printf("Querying custom IE successful\n");
3811 (tlvbuf_custom_ie *) (buffer +
3812 sizeof(APCMDBUF_SYS_CONFIGURE));
3813 print_tlv((u8 *) tlv,
3814 cmd_buf->Size - sizeof(APCMDBUF_SYS_CONFIGURE) +
3818 if ((argc != 0) && (argc != 1))
3819 printf("ERR:Could not set custom IE elements!\n");
3821 printf("ERR:Could not get custom IE elements!\n");
3824 printf("ERR:Command sending failed!\n");
3832 * @brief Creates a sys_cfg request for cipher configurations
3833 * and sends to the driver
3835 * Usage: "sys_cfg_security_cfg [PAIRWISE_CIPHER GROUP_CIPHER]"
3837 * Options: PAIRWISE_CIPHER : Bit 2 - TKIP
3839 * GROUP_CIPHER : Bit 2 - TKIP
3841 * empty - Get current cipher settings
3843 * @param argc Number of arguments
3844 * @param argv Pointer to the arguments
3848 apcmd_sys_cfg_cipher(int argc, char *argv[])
3850 APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
3851 TLVBUF_CIPHER *tlv = NULL;
3854 int ret = UAP_FAILURE;
3856 while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
3859 print_sys_cfg_cipher_usage();
3866 /* Check arguments */
3867 if ((argc != 0) && (argc != 2)) {
3868 printf("ERR:wrong arguments.\n");
3869 print_sys_cfg_cipher_usage();
3873 if ((ISDIGIT(argv[0]) == 0) || (ISDIGIT(argv[1]) == 0)) {
3874 print_sys_cfg_cipher_usage();
3877 if (atoi(argv[0]) & ~CIPHER_BITMAP) {
3878 printf("ERR:Illegal PAIRWISE_CIPHER parameter %s.\n", argv[0]);
3879 print_sys_cfg_cipher_usage();
3882 if (atoi(argv[1]) & ~CIPHER_BITMAP) {
3883 printf("ERR:Illegal GROUP_CIPHER parameter %s.\n", argv[1]);
3884 print_sys_cfg_cipher_usage();
3887 if (is_cipher_valid(atoi(argv[0]), atoi(argv[1])) != UAP_SUCCESS) {
3888 printf("ERR:Wrong group and pair cipher combination!\n");
3889 print_sys_cfg_cipher_usage();
3893 /* Initialize the command length */
3894 cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_CIPHER);
3896 /* Initialize the command buffer */
3897 buffer = (u8 *) malloc(cmd_len);
3900 printf("ERR:Cannot allocate buffer for command!\n");
3903 bzero((char *) buffer, cmd_len);
3905 /* Locate headers */
3906 cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
3907 tlv = (TLVBUF_CIPHER *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));
3908 /* Fill the command buffer */
3909 cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
3910 cmd_buf->Size = cmd_len;
3911 cmd_buf->SeqNum = 0;
3912 cmd_buf->Result = 0;
3913 tlv->Tag = MRVL_CIPHER_TLV_ID;
3916 cmd_buf->Action = ACTION_GET;
3918 cmd_buf->Action = ACTION_SET;
3919 tlv->PairwiseCipher = (u8) atoi(argv[0]);
3920 tlv->GroupCipher = (u8) atoi(argv[1]);
3922 endian_convert_tlv_header_out(tlv);
3923 /* Send the command */
3924 ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
3925 endian_convert_tlv_header_in(tlv);
3926 /* Process response */
3927 if (ret == UAP_SUCCESS) {
3928 /* Verify response */
3929 if ((cmd_buf->CmdCode != (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) ||
3930 (tlv->Tag != MRVL_CIPHER_TLV_ID)) {
3931 printf("ERR:Corrupted response! CmdCode=%x, Tlv->Tag=%x\n",
3932 cmd_buf->CmdCode, tlv->Tag);
3936 /* Print response */
3937 if (cmd_buf->Result == CMD_SUCCESS) {
3941 printf("cipher setting successful\n");
3945 printf("ERR:Could not get cipher parameters!\n");
3947 printf("ERR:Could not set cipher parameters!\n");
3951 printf("ERR:Command sending failed!\n");
3959 * @brief Creates a sys_cfg request for group re-key timer
3960 * and sends to the driver
3962 * Usage: "Usage : sys_cfg_group_rekey_timer [GROUP_REKEY_TIMER]"
3964 * Options: GROUP_REKEY_TIME is represented in seconds
3965 * Get current group re-key timer
3967 * @param argc Number of arguments
3968 * @param argv Pointer to the arguments
3972 apcmd_sys_cfg_group_rekey_timer(int argc, char *argv[])
3974 APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
3975 TLVBUF_GROUP_REKEY_TIMER *tlv = NULL;
3978 int ret = UAP_FAILURE;
3980 while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
3983 print_sys_cfg_group_rekey_timer_usage();
3989 /* Check arguments */
3990 if (argc && (is_input_valid(GROUPREKEYTIMER, argc, argv) != UAP_SUCCESS)) {
3991 print_sys_cfg_group_rekey_timer_usage();
3994 /* Initialize the command length */
3995 cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_GROUP_REKEY_TIMER);
3996 /* Initialize the command buffer */
3997 buffer = (u8 *) malloc(cmd_len);
3999 printf("ERR:Cannot allocate buffer for command!\n");
4002 bzero((char *) buffer, cmd_len);
4003 /* Locate headers */
4004 cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
4006 (TLVBUF_GROUP_REKEY_TIMER *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));
4008 /* Fill the command buffer */
4009 cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
4010 cmd_buf->Size = cmd_len;
4011 cmd_buf->SeqNum = 0;
4012 cmd_buf->Result = 0;
4013 tlv->Tag = MRVL_GRP_REKEY_TIME_TLV_ID;
4016 cmd_buf->Action = ACTION_GET;
4018 cmd_buf->Action = ACTION_SET;
4019 tlv->GroupRekeyTime_sec = (u32) atoi(argv[0]);
4021 endian_convert_tlv_header_out(tlv);
4022 tlv->GroupRekeyTime_sec = uap_cpu_to_le32(tlv->GroupRekeyTime_sec);
4023 /* Send the command */
4024 ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
4025 endian_convert_tlv_header_in(tlv);
4026 tlv->GroupRekeyTime_sec = uap_le32_to_cpu(tlv->GroupRekeyTime_sec);
4027 /* Process response */
4028 if (ret == UAP_SUCCESS) {
4029 /* Verify response */
4030 if ((cmd_buf->CmdCode != (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) ||
4031 (tlv->Tag != MRVL_GRP_REKEY_TIME_TLV_ID)) {
4032 printf("ERR:Corrupted response! CmdCode=%x, Tlv->Tag=%x\n",
4033 cmd_buf->CmdCode, tlv->Tag);
4037 /* Print response */
4038 if (cmd_buf->Result == CMD_SUCCESS) {
4040 if (tlv->GroupRekeyTime_sec > 0)
4041 printf("Group rekey time is %ld s\n",
4042 tlv->GroupRekeyTime_sec);
4044 printf("Group rekey time is disabled\n");
4046 printf("group re-key time setting successful\n");
4050 printf("ERR:Could not get group re-key time!\n");
4052 printf("ERR:Could not set group re-key time!\n");
4056 printf("ERR:Command sending failed!\n");
4064 * @brief Creates a sys_cfg request for WPA passphrase
4065 * and sends to the driver
4067 * Usage: "sys_cfg_wpa_passphrase [PASSPHRASE]"
4068 * if PASSPHRASE is provided, a 'set' is performed
4069 * else a 'get' is performed
4071 * @param argc Number of arguments
4072 * @param argv Pointer to the arguments
4076 apcmd_sys_cfg_wpa_passphrase(int argc, char *argv[])
4078 APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
4079 TLVBUF_WPA_PASSPHRASE *tlv = NULL;
4082 int ret = UAP_FAILURE;
4084 while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
4087 print_sys_cfg_wpa_passphrase_usage();
4093 /* Check arguments */
4095 printf("ERR:Too many arguments.\n");
4096 print_sys_cfg_wpa_passphrase_usage();
4099 if ((argc == 1) && (strlen(argv[0]) > MAX_WPA_PASSPHRASE_LENGTH)) {
4100 printf("ERR:PASSPHRASE too long.\n");
4103 if ((argc == 1) && (strlen(argv[0]) < MIN_WPA_PASSPHRASE_LENGTH)) {
4104 printf("ERR:PASSPHRASE too short.\n");
4107 if ((argc == 1) && (strlen(argv[0]) == MAX_WPA_PASSPHRASE_LENGTH)) {
4108 if (UAP_FAILURE == ishexstring(argv[0])) {
4110 ("ERR:Only hex digits are allowed when passphrase's length is 64\n");
4114 /* Initialize the command length */
4117 sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_WPA_PASSPHRASE) +
4118 MAX_WPA_PASSPHRASE_LENGTH;
4121 sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_WPA_PASSPHRASE) +
4123 /* Initialize the command buffer */
4124 buffer = (u8 *) malloc(cmd_len);
4126 printf("ERR:Cannot allocate buffer for command!\n");
4129 bzero((char *) buffer, cmd_len);
4130 /* Locate headers */
4131 cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
4132 tlv = (TLVBUF_WPA_PASSPHRASE *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));
4133 /* Fill the command buffer */
4134 cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
4135 cmd_buf->Size = cmd_len;
4136 cmd_buf->SeqNum = 0;
4137 cmd_buf->Result = 0;
4138 tlv->Tag = MRVL_WPA_PASSPHRASE_TLV_ID;
4140 cmd_buf->Action = ACTION_GET;
4141 tlv->Length = MAX_WPA_PASSPHRASE_LENGTH;
4143 cmd_buf->Action = ACTION_SET;
4144 tlv->Length = strlen(argv[0]);
4145 memcpy(tlv->Passphrase, argv[0], tlv->Length);
4147 endian_convert_tlv_header_out(tlv);
4148 /* Send the command */
4149 ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
4150 endian_convert_tlv_header_in(tlv);
4151 /* Process response */
4152 if (ret == UAP_SUCCESS) {
4153 /* Verify response */
4154 if ((cmd_buf->CmdCode != (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) ||
4155 (tlv->Tag != MRVL_WPA_PASSPHRASE_TLV_ID)) {
4156 printf("ERR:Corrupted response! CmdCode=%x, Tlv->Tag=%x\n",
4157 cmd_buf->CmdCode, tlv->Tag);
4161 /* Print response */
4162 if (cmd_buf->Result == CMD_SUCCESS) {
4164 if (tlv->Length > 0)
4165 printf("WPA passphrase = %s\n", tlv->Passphrase);
4167 printf("WPA passphrase: None\n");
4169 printf("WPA passphrase setting successful\n");
4173 printf("ERR:Could not get WPA passphrase!\n");
4175 printf("ERR:Could not set WPA passphrase!\n");
4179 printf("ERR:Command sending failed!\n");
4187 * @brief Creates a STA filter request and sends to the driver
4189 * Usage: "sta_filter_table <FILTERMODE> <MACADDRESS_LIST>"
4191 * Options: FILTERMODE : 0 - Disable filter table
4192 * 1 - Allow mac address specified in the allwed list
4193 * 2 - Block MAC addresses specified in the banned list
4194 * MACADDRESS_LIST is the list of MAC addresses to be acted upon. Each
4195 * MAC address must be separated with a space. Maximum of
4196 * 16 MAC addresses are supported.
4198 * @param argc Number of arguments
4199 * @param argv Pointer to the arguments
4203 apcmd_sta_filter_table(int argc, char *argv[])
4205 APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
4206 TLVBUF_STA_MAC_ADDR_FILTER *tlv = NULL;
4209 int ret = UAP_FAILURE;
4212 while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
4215 print_sta_filter_table_usage();
4221 /* Check arguments */
4222 if (argc > (MAX_MAC_ONESHOT_FILTER + 1)) {
4223 printf("ERR:Too many arguments.\n");
4224 print_sta_filter_table_usage();
4228 if ((ISDIGIT(argv[0]) == 0) ||
4229 ((atoi(argv[0]) < 0) || (atoi(argv[0]) > 2))) {
4231 ("ERR:Illegal FILTERMODE parameter %s. Must be either '0', '1', or '2'.\n",
4233 print_sta_filter_table_usage();
4236 if ((atoi(argv[0]) != 0) && (argc == 1)) {
4237 printf("ERR:At least one mac is required.\n");
4238 print_sta_filter_table_usage();
4242 /* Initialize the command length */
4245 sizeof(APCMDBUF_SYS_CONFIGURE) +
4246 sizeof(TLVBUF_STA_MAC_ADDR_FILTER) +
4247 (MAX_MAC_ONESHOT_FILTER * ETH_ALEN);
4250 sizeof(APCMDBUF_SYS_CONFIGURE) +
4251 sizeof(TLVBUF_STA_MAC_ADDR_FILTER) + (argc - 1) * ETH_ALEN;
4254 /* Initialize the command buffer */
4255 buffer = (u8 *) malloc(cmd_len);
4258 printf("ERR:Cannot allocate buffer for command!\n");
4261 bzero((char *) buffer, cmd_len);
4262 /* Locate headers */
4263 cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
4265 (TLVBUF_STA_MAC_ADDR_FILTER *) (buffer +
4266 sizeof(APCMDBUF_SYS_CONFIGURE));
4268 /* Fill the command buffer */
4269 cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
4270 cmd_buf->Size = cmd_len;
4271 cmd_buf->SeqNum = 0;
4272 cmd_buf->Result = 0;
4273 tlv->Tag = MRVL_STA_MAC_ADDR_FILTER_TLV_ID;
4275 cmd_buf->Action = ACTION_GET;
4276 tlv->Count = MAX_MAC_ONESHOT_FILTER;
4278 cmd_buf->Action = ACTION_SET;
4279 tlv->FilterMode = atoi(argv[0]);
4280 tlv->Count = argc - 1;
4281 for (i = 0; i < tlv->Count; i++) {
4283 mac2raw(argv[i + 1],
4284 &tlv->MacAddress[i * ETH_ALEN])) != UAP_SUCCESS) {
4285 printf("ERR: %s Address\n",
4286 ret == UAP_FAILURE ? "Invalid MAC" : ret ==
4287 UAP_RET_MAC_BROADCAST ? "Broadcast" : "Multicast");
4288 print_sta_filter_table_usage();
4294 tlv->Length = tlv->Count * ETH_ALEN + 2;
4295 endian_convert_tlv_header_out(tlv);
4296 /* Send the command */
4297 ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
4298 endian_convert_tlv_header_in(tlv);
4299 /* Process response */
4300 if (ret == UAP_SUCCESS) {
4301 /* Verify response */
4302 if ((cmd_buf->CmdCode != (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) ||
4303 (tlv->Tag != MRVL_STA_MAC_ADDR_FILTER_TLV_ID)) {
4304 printf("ERR:Corrupted response! CmdCode=%x, Tlv->Tag=%x\n",
4305 cmd_buf->CmdCode, tlv->Tag);
4309 /* Print response */
4310 if (cmd_buf->Result == CMD_SUCCESS) {
4312 print_mac_filter(tlv);
4314 printf("MAC address filter table setting successful!\n");
4319 ("ERR:Could not get MAC address filter table settings!\n");
4322 ("ERR:Could not set MAC address filter table settings!\n");
4326 printf("ERR:Command sending failed!\n");
4334 * @brief Creates a sys_cfg request for max station number
4335 * and sends to the driver
4337 * Usage: "sys_cfg_max_sta_num [STA_NUM]"
4338 * if STA_NUM is provided, a 'set' is performed
4339 * else a 'get' is performed.
4341 * STA_NUM should not bigger than 8
4343 * @param argc Number of arguments
4344 * @param argv Pointer to the arguments
4348 apcmd_sys_cfg_max_sta_num(int argc, char *argv[])
4350 APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
4351 TLVBUF_MAX_STA_NUM *tlv = NULL;
4354 int ret = UAP_FAILURE;
4357 while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
4360 print_sys_cfg_max_sta_num_usage();
4367 /* Check arguments */
4368 if (argc && (is_input_valid(MAXSTANUM, argc, argv) != UAP_SUCCESS)) {
4369 print_sys_cfg_max_sta_num_usage();
4373 /* Initialize the command length */
4374 cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_MAX_STA_NUM);
4376 /* Initialize the command buffer */
4377 buffer = (u8 *) malloc(cmd_len);
4380 printf("ERR:Cannot allocate buffer for command!\n");
4383 bzero((char *) buffer, cmd_len);
4385 /* Locate headers */
4386 cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
4387 tlv = (TLVBUF_MAX_STA_NUM *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));
4389 /* Fill the command buffer */
4390 cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
4391 cmd_buf->Size = cmd_len;
4392 cmd_buf->SeqNum = 0;
4393 cmd_buf->Result = 0;
4394 tlv->Tag = MRVL_MAX_STA_CNT_TLV_ID;
4397 cmd_buf->Action = ACTION_GET;
4399 cmd_buf->Action = ACTION_SET;
4400 tlv->Max_sta_num = (u16) atoi(argv[0]);
4402 endian_convert_tlv_header_out(tlv);
4403 tlv->Max_sta_num = uap_cpu_to_le16(tlv->Max_sta_num);
4405 /* Send the command */
4406 ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
4407 endian_convert_tlv_header_in(tlv);
4408 tlv->Max_sta_num = uap_le16_to_cpu(tlv->Max_sta_num);
4409 /* Process response */
4410 if (ret == UAP_SUCCESS) {
4411 /* Verify response */
4412 if ((cmd_buf->CmdCode != (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) ||
4413 (tlv->Tag != MRVL_MAX_STA_CNT_TLV_ID)) {
4414 printf("ERR:Corrupted response! CmdCode=%x, Tlv->Tag=%x\n",
4415 cmd_buf->CmdCode, tlv->Tag);
4419 /* Print response */
4420 if (cmd_buf->Result == CMD_SUCCESS) {
4422 printf("max station number = %d\n", tlv->Max_sta_num);
4424 printf("max station number setting successful\n");
4428 printf("ERR:Could not get max station number!\n");
4430 printf("ERR:Could not set max station number!\n");
4434 printf("ERR:Command sending failed!\n");
4442 * @brief Creates a sys_cfg request for retry limit
4443 * and sends to the driver
4445 * Usage: "sys_cfg_retry_limit [RETRY_LIMIT]"
4446 * if RETRY_LIMIT is provided, a 'set' is performed
4447 * else a 'get' is performed.
4449 * RETRY_LIMIT should not bigger than 14
4451 * @param argc Number of arguments
4452 * @param argv Pointer to the arguments
4456 apcmd_sys_cfg_retry_limit(int argc, char *argv[])
4458 APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
4459 TLVBUF_RETRY_LIMIT *tlv = NULL;
4462 int ret = UAP_FAILURE;
4465 while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
4468 print_sys_cfg_max_sta_num_usage();
4475 /* Check arguments */
4476 if (argc && (is_input_valid(RETRYLIMIT, argc, argv) != UAP_SUCCESS)) {
4477 print_sys_cfg_retry_limit_usage();
4481 /* Initialize the command length */
4482 cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_RETRY_LIMIT);
4484 /* Initialize the command buffer */
4485 buffer = (u8 *) malloc(cmd_len);
4488 printf("ERR:Cannot allocate buffer for command!\n");
4491 bzero((char *) buffer, cmd_len);
4493 /* Locate headers */
4494 cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
4495 tlv = (TLVBUF_RETRY_LIMIT *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));
4497 /* Fill the command buffer */
4498 cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
4499 cmd_buf->Size = cmd_len;
4500 cmd_buf->SeqNum = 0;
4501 cmd_buf->Result = 0;
4502 tlv->Tag = MRVL_RETRY_LIMIT_TLV_ID;
4505 cmd_buf->Action = ACTION_GET;
4507 cmd_buf->Action = ACTION_SET;
4508 tlv->retry_limit = (u8) atoi(argv[0]);
4510 endian_convert_tlv_header_out(tlv);
4512 /* Send the command */
4513 ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
4514 endian_convert_tlv_header_in(tlv);
4516 /* Process response */
4517 if (ret == UAP_SUCCESS) {
4518 /* Verify response */
4519 if ((cmd_buf->CmdCode != (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) ||
4520 (tlv->Tag != MRVL_RETRY_LIMIT_TLV_ID)) {
4521 printf("ERR:Corrupted response! CmdCode=%x, Tlv->Tag=%x\n",
4522 cmd_buf->CmdCode, tlv->Tag);
4526 /* Print response */
4527 if (cmd_buf->Result == CMD_SUCCESS) {
4529 printf("retry limit = %d\n", tlv->retry_limit);
4531 printf("retry limit setting successful\n");
4535 printf("ERR:Could not get retry limit!\n");
4537 printf("ERR:Could not set retry limit!\n");
4541 printf("ERR:Command sending failed!\n");
4549 * @brief convert string to integer
4551 * @param ptr A pointer to data buffer
4552 * @param chr A pointer to return integer
4553 * @return A pointer to next data field
4556 convert2hex(char *ptr, u8 * chr)
4560 for (val = 0; *ptr && isxdigit(*ptr); ptr++) {
4561 val = (val * 16) + hexc2bin(*ptr);
4570 * @brief parse hex data
4571 * @param fp A pointer to FILE stream
4572 * @param dst A pointer to receive hex data
4573 * @return length of hex data
4576 fparse_for_hex(FILE * fp, u8 * dst)
4583 while (fgets(buf, sizeof(buf), fp)) {
4587 /* skip leading spaces */
4588 while (*ptr && (isspace(*ptr) || *ptr == '\t'))
4591 /* skip blank lines and lines beginning with '#' */
4592 if (*ptr == '\0' || *ptr == '#')
4595 if (isxdigit(*ptr)) {
4596 ptr = convert2hex(ptr, dptr++);
4598 /* Invalid character on data line */
4604 return (dptr - dst);
4608 * @brief Creates a cfg_data request
4609 * and sends to the driver
4611 * Usage: "cfg_data <cfg_data.conf>"
4613 * @param argc Number of arguments
4614 * @param argv Pointer to the arguments
4618 apcmd_cfg_data(int argc, char *argv[])
4620 APCMDBUF_CFG_DATA *cmd_buf = NULL;
4624 int ret = UAP_FAILURE;
4627 while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
4630 print_cfg_data_usage();
4637 /* Check arguments */
4638 if ((argc == 0) || (argc > 2)) {
4639 printf("ERR:wrong arguments.\n");
4640 print_cfg_data_usage();
4643 if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) != 2)) {
4644 printf("ERR:Illegal type parameter %s. Must be '2'.\n", argv[0]);
4645 print_cfg_data_usage();
4649 buf_len = MRVDRV_SIZE_OF_CMD_BUFFER;
4650 buf = (u8 *) malloc(buf_len);
4651 memset(buf, 0, buf_len);
4652 cmd_buf = (APCMDBUF_CFG_DATA *) buf;
4654 printf("Error: allocate memory for hostcmd failed\n");
4658 /* Check if file exists */
4659 fp = fopen(argv[1], "r");
4661 printf("\nERR:Config file can not open %s.\n", argv[1]);
4665 cmd_buf->action = ACTION_SET;
4666 cmd_buf->data_len = fparse_for_hex(fp, cmd_buf->data);
4668 if (cmd_buf->data_len > MAX_CFG_DATA_SIZE) {
4669 printf("ERR: Config file is too big %d\n", cmd_buf->data_len);
4674 cmd_buf->action = ACTION_GET;
4675 cmd_buf->data_len = 0;
4678 cmd_buf->action = uap_cpu_to_le16(cmd_buf->action);
4679 cmd_buf->type = atoi(argv[0]);
4680 cmd_buf->type = uap_cpu_to_le16(cmd_buf->type);
4681 cmd_buf->data_len = uap_cpu_to_le16(cmd_buf->data_len);
4683 /* Fill the command buffer */
4684 cmd_len = cmd_buf->data_len + sizeof(APCMDBUF_CFG_DATA);
4685 cmd_buf->CmdCode = HostCmd_CMD_CFG_DATA;
4686 cmd_buf->Size = cmd_len;
4687 cmd_buf->SeqNum = 0;
4688 cmd_buf->Result = 0;
4690 /* Send the command */
4691 ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, buf_len);
4692 /* Process response */
4693 if (ret == UAP_SUCCESS) {
4694 cmd_buf->action = uap_le16_to_cpu(cmd_buf->action);
4695 cmd_buf->data_len = uap_le16_to_cpu(cmd_buf->data_len);
4696 if (cmd_buf->action == ACTION_GET) {
4697 hexdump_data("cfg_data", cmd_buf->data, cmd_buf->data_len, ' ');
4699 printf("download cfg data successful\n");