Logo Search packages:      
Sourcecode: uaputl version File versions  Download package

void apcmd_sys_config_profile ( int  argc,
char *  argv[] 
)

Read the profile and sends to the driver.

Parameters:
argcNumber of arguments
argvPointer to the arguments
Returns:
UAP_SUCCESS or UAP_FAILURE

Definition at line 2079 of file uaputl.c.

References A2HEXDECIMAL, ACTION_SET, APCMD_SYS_CONFIGURE, BAND_CONFIG_ACS_MODE, BASIC_RATE_SET_BIT, BUF_HEADER_SIZE, CIPHER_BITMAP, config_get_line(), endian_convert_tlv_header_out, ETH_ALEN, hexdump(), HostCmd_CMD_802_11D_DOMAIN_INFO, is_cipher_valid(), IS_HEX_OR_DIGIT, is_input_valid(), is_mcbc_rate_valid(), is_tx_rate_valid(), ISDIGIT(), ishexstring(), KEY_MGMT_PSK, mac2raw(), MAX_CONFIG_LINE, MAX_CUSTOM_IE_COUNT, MAX_IE_BUFFER_LEN, MAX_MAC_ONESHOT_FILTER, MAX_RATES, MAX_SSID_LENGTH, MAX_SUB_BANDS, MAX_WPA_PASSPHRASE_LENGTH, MIN_SSID_LENGTH, MIN_WPA_PASSPHRASE_LENGTH, MRVL_AKMP_TLV_ID, MRVL_ANTENNA_CTL_TLV_ID, MRVL_AP_MAC_ADDRESS_TLV_ID, MRVL_AUTH_TLV_ID, MRVL_BCAST_SSID_CTL_TLV_ID, MRVL_BEACON_PERIOD_TLV_ID, MRVL_CHANNELCONFIG_TLV_ID, MRVL_CHANNELLIST_TLV_ID, MRVL_CIPHER_TLV_ID, MRVL_DTIM_PERIOD_TLV_ID, MRVL_FRAG_THRESHOLD_TLV_ID, MRVL_GRP_REKEY_TIME_TLV_ID, MRVL_MAX_STA_CNT_TLV_ID, MRVL_MCBC_DATA_RATE_TLV_ID, MRVL_MGMT_IE_LIST_TLV_ID, MRVL_PKT_FWD_CTL_TLV_ID, MRVL_PROTOCOL_TLV_ID, MRVL_RADIO_CTL_TLV_ID, MRVL_RATES_TLV_ID, MRVL_RETRY_LIMIT_TLV_ID, MRVL_RSN_REPLAY_PROT_TLV_ID, MRVL_RTS_THRESHOLD_TLV_ID, MRVL_SSID_TLV_ID, MRVL_STA_AGEOUT_TIMER_TLV_ID, MRVL_STA_MAC_ADDR_FILTER_TLV_ID, MRVL_TX_DATA_RATE_TLV_ID, MRVL_TX_POWER_TLV_ID, MRVL_WEP_KEY_TLV_ID, MRVL_WPA_PASSPHRASE_TLV_ID, OID_80211D_ENABLE, parse_domain_file(), parse_line(), PROTOCOL_WPA, PROTOCOL_WPA2, sg_snmp_mib(), string2raw(), TLV_TYPE_DOMAIN, uap_cpu_to_le16, uap_cpu_to_le32, UAP_FAILURE, uap_ioctl(), uap_printf(), UAP_RET_MAC_BROADCAST, and UAP_SUCCESS.

Referenced by apcmd_sys_config().

{
    FILE *config_file = NULL;
    char *line = NULL;
    int li = 0;
    char *pos = NULL;
    int arg_num = 0;
    char *args[30];
    int i;
    int is_ap_config = 0;
    int is_custom_ie_config = 0;
    int is_ap_mac_filter = 0;
    APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
    u8 *buffer = NULL;
    u16 cmd_len = 0;
    u16 tlv_len = 0;
    u16 ie_len = 0;
    u16 ie_buf_len = 0;
    u16 mask_ie_index = 0;
    int keyindex = -1;
    int pairwisecipher = -1;
    int groupcipher = -1;
    TLVBUF_STA_MAC_ADDR_FILTER *filter_tlv = NULL;
    tlvbuf_custom_ie *custom_ie_tlv_head = NULL;
    tlvbuf_custom_ie *custom_ie_tlv = NULL;
    custom_ie *custom_ie_ptr = NULL;
    int custom_ie_tlv_len = 0;
    int custom_mask_count = 0;
    int custom_buf_count = 0;
    int filter_mac_count = -1;
    int tx_data_rate = -1;
    int mcbc_data_rate = -1;
    u8 rate[MAX_RATES];
    int found = 0;
    char country_80211d[4];
    u8 state_80211d;
    int flag_80211d = 0;

    memset(rate, 0, MAX_RATES);
    /* Check if file exists */
    config_file = fopen(argv[0], "r");
    if (config_file == NULL) {
        printf("\nERR:Config file can not open.\n");
        return;
    }
    line = (char *) malloc(MAX_CONFIG_LINE);
    if (!line) {
        printf("ERR:Cannot allocate memory for line\n");
        goto done;
    }
    bzero(line, MAX_CONFIG_LINE);

    /* Parse file and process */
    while (config_get_line(line, MAX_CONFIG_LINE, config_file, &li, &pos)) {
#if DEBUG
        uap_printf(MSG_DEBUG, "DBG:Received config line (%d) = %s\n", li, line);
#endif
        arg_num = parse_line(line, args);
#if DEBUG
        uap_printf(MSG_DEBUG, "DBG:Number of arguments = %d\n", arg_num);
        for (i = 0; i < arg_num; i++) {
            uap_printf(MSG_DEBUG, "\tDBG:Argument %d. %s\n", i + 1, args[i]);
        }
#endif
        /* Check for end of AP configurations */
        if (is_ap_config == 1) {
            if (strcmp(args[0], "}") == 0) {
                is_ap_config = 0;
                if (tx_data_rate != -1) {
                    if ((!rate[0]) && (tx_data_rate) &&
                        (is_tx_rate_valid((u8) tx_data_rate) != UAP_SUCCESS)) {
                        printf("ERR: Invalid Tx Data Rate \n");
                        goto done;
                    }
                    if (rate[0] && tx_data_rate) {
                        for (i = 0; rate[i] != 0; i++) {
                            if ((rate[i] & ~BASIC_RATE_SET_BIT) == tx_data_rate) {
                                found = 1;
                                break;
                            }
                        }
                        if (!found) {
                            printf("ERR: Invalid Tx Data Rate \n");
                            goto done;
                        }
                    }

                    /* Append a new TLV */
                    TLVBUF_TX_DATA_RATE *tlv = NULL;
                    tlv_len = sizeof(TLVBUF_TX_DATA_RATE);
                    buffer = realloc(buffer, cmd_len + tlv_len);
                    if (!buffer) {
                        printf("ERR:Cannot append tx data rate TLV!\n");
                        goto done;
                    }
                    cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
                    tlv = (TLVBUF_TX_DATA_RATE *) (buffer + cmd_len);
                    cmd_len += tlv_len;
                    /* Set TLV fields */
                    tlv->Tag = MRVL_TX_DATA_RATE_TLV_ID;
                    tlv->Length = 2;
                    tlv->TxDataRate = tx_data_rate;
                    endian_convert_tlv_header_out(tlv);
                    tlv->TxDataRate = uap_cpu_to_le16(tlv->TxDataRate);
                }
                if (mcbc_data_rate != -1) {
                    if ((!rate[0]) && (mcbc_data_rate) &&
                        (is_mcbc_rate_valid((u8) mcbc_data_rate) !=
                         UAP_SUCCESS)) {
                        printf("ERR: Invalid Tx Data Rate \n");
                        goto done;
                    }
                    if (rate[0] && mcbc_data_rate) {
                        for (i = 0; rate[i] != 0; i++) {
                            if (rate[i] & BASIC_RATE_SET_BIT) {
                                if ((rate[i] & ~BASIC_RATE_SET_BIT) ==
                                    mcbc_data_rate) {
                                    found = 1;
                                    break;
                                }
                            }
                        }
                        if (!found) {
                            printf("ERR: Invalid MCBC Data Rate \n");
                            goto done;
                        }
                    }

                    /* Append a new TLV */
                    TLVBUF_MCBC_DATA_RATE *tlv = NULL;
                    tlv_len = sizeof(TLVBUF_MCBC_DATA_RATE);
                    buffer = realloc(buffer, cmd_len + tlv_len);
                    if (!buffer) {
                        printf("ERR:Cannot append tx data rate TLV!\n");
                        goto done;
                    }
                    cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
                    tlv = (TLVBUF_MCBC_DATA_RATE *) (buffer + cmd_len);
                    cmd_len += tlv_len;
                    /* Set TLV fields */
                    tlv->Tag = MRVL_MCBC_DATA_RATE_TLV_ID;
                    tlv->Length = 2;
                    tlv->MCBCdatarate = mcbc_data_rate;
                    endian_convert_tlv_header_out(tlv);
                    tlv->MCBCdatarate = uap_cpu_to_le16(tlv->MCBCdatarate);
                }

                if ((pairwisecipher >= 0) && (groupcipher >= 0)) {
                    if (is_cipher_valid(pairwisecipher, groupcipher) !=
                        UAP_SUCCESS) {
                        printf
                            ("ERR:Wrong group and pair cipher combination!\n");
                        goto done;
                    }
                    TLVBUF_CIPHER *tlv = NULL;
                    /* Append a new TLV */
                    tlv_len = sizeof(TLVBUF_CIPHER);
                    buffer = realloc(buffer, cmd_len + tlv_len);
                    if (!buffer) {
                        printf("ERR:Cannot append cipher TLV!\n");
                        goto done;
                    }
                    cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
                    tlv = (TLVBUF_CIPHER *) (buffer + cmd_len);
                    bzero((char *) tlv, tlv_len);
                    cmd_len += tlv_len;
                    /* Set TLV fields */
                    tlv->Tag = MRVL_CIPHER_TLV_ID;
                    tlv->Length = 2;
                    tlv->PairwiseCipher = pairwisecipher;
                    tlv->GroupCipher = groupcipher;
                    endian_convert_tlv_header_out(tlv);
                }
                cmd_buf->Size = cmd_len;
                /* Send collective command */
                uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
                cmd_len = 0;
                if (buffer) {
                    free(buffer);
                    buffer = NULL;
                }
                continue;
            }
        }

        /* Check for beginning of AP configurations */
        if (strcmp(args[0], "ap_config") == 0) {
            is_ap_config = 1;
            cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE);
            if (buffer) {
                free(buffer);
                buffer = NULL;
            }
            buffer = (u8 *) malloc(cmd_len);
            if (!buffer) {
                printf("ERR:Cannot allocate memory!\n");
                goto done;
            }
            cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
            cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
            cmd_buf->Size = cmd_len;
            cmd_buf->SeqNum = 0;
            cmd_buf->Result = 0;
            cmd_buf->Action = ACTION_SET;
            continue;
        }

        /* Check for end of AP MAC address filter configurations */
        if (is_ap_mac_filter == 1) {
            if (strcmp(args[0], "}") == 0) {
                is_ap_mac_filter = 0;
                if (filter_tlv->Count != filter_mac_count) {
                    printf
                        ("ERR:Number of MAC address provided does not match 'Count'\n");
                    goto done;
                }
                if (filter_tlv->FilterMode && (filter_tlv->Count == 0)) {
                    printf
                        ("ERR:Filter list can not be empty for %s Filter mode\n",
                         (filter_tlv->FilterMode == 1) ? "'Allow'" : "'Block'");
                    goto done;
                }
                filter_tlv->Length = (filter_tlv->Count * ETH_ALEN) + 2;
                cmd_len -=
                    (MAX_MAC_ONESHOT_FILTER - filter_mac_count) * ETH_ALEN;
                cmd_buf->Size = cmd_len;
                endian_convert_tlv_header_out(filter_tlv);
                uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
                cmd_len = 0;
                if (buffer) {
                    free(buffer);
                    buffer = NULL;
                }
                continue;
            }
        }

        /* Check for end of custom IE configurations */
        if (is_custom_ie_config == 1) {
            if (strcmp(args[0], "}") == 0) {
                if (custom_mask_count != custom_buf_count) {
                    printf
                        ("ERR:custom IE mask count and buffer count does not match\n");
                    goto done;
                }
                is_custom_ie_config = 0;
                custom_ie_tlv_head->Length = custom_ie_tlv_len;
                cmd_len -=
                    (MAX_IE_BUFFER_LEN * MAX_CUSTOM_IE_COUNT) -
                    custom_ie_tlv_len;
                cmd_len -= sizeof(custom_ie) * MAX_CUSTOM_IE_COUNT;
                cmd_buf->Size = cmd_len;
                endian_convert_tlv_header_out(custom_ie_tlv_head);
                uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
                cmd_len = 0;
                if (buffer) {
                    free(buffer);
                    buffer = NULL;
                }
                continue;
            }
        }

        if (flag_80211d && (strcmp(args[0], "11d_enable") == 0)) {
            if (IS_HEX_OR_DIGIT(args[1]) == UAP_FAILURE) {
                printf("ERR: valid input for state are 0 or 1\n");
                goto done;
            }
            state_80211d = (u8) A2HEXDECIMAL(args[1]);

            if ((state_80211d != 0) && (state_80211d != 1)) {
                printf("ERR: valid input for state are 0 or 1 \n");
                goto done;
            }
            if (sg_snmp_mib
                (ACTION_SET, OID_80211D_ENABLE, sizeof(state_80211d),
                 &state_80211d)
                == UAP_FAILURE) {
                goto done;
            }
        }

        if (strcmp(args[0], "country") == 0) {
            APCMDBUF_CFG_80211D *cmd_buf = NULL;
            IEEEtypes_SubbandSet_t sub_bands[MAX_SUB_BANDS];
            u8 no_of_sub_band = 0;
            u16 buf_len;
            u16 cmdlen;
            u8 *buf = NULL;

            if ((strlen(args[1]) > 3) || (strlen(args[1]) < 0)) {
                printf("In-correct country input\n");
                goto done;
            }
            strcpy(country_80211d, args[1]);
            for (i = 0; i < strlen(country_80211d); i++) {
                if ((country_80211d[i] < 'A') || (country_80211d[i] > 'z')) {
                    printf("Invalid Country Code\n");
                    goto done;
                }
                if (country_80211d[i] > 'Z')
                    country_80211d[i] = country_80211d[i] - 'a' + 'A';
            }
            no_of_sub_band = parse_domain_file(country_80211d, sub_bands);
            if (no_of_sub_band == UAP_FAILURE) {
                printf("Parsing Failed\n");
                goto done;
            }
            buf_len = sizeof(APCMDBUF_CFG_80211D);
            buf_len += no_of_sub_band * sizeof(IEEEtypes_SubbandSet_t);
            buf = (u8 *) malloc(buf_len);
            if (!buf) {
                printf("ERR:Cannot allocate buffer from command!\n");
                goto done;
            }
            bzero((char *) buf, buf_len);
            cmd_buf = (APCMDBUF_CFG_80211D *) buf;
            cmdlen = buf_len;
            cmd_buf->Size = cmdlen - BUF_HEADER_SIZE;
            cmd_buf->Result = 0;
            cmd_buf->SeqNum = 0;
            cmd_buf->Action = uap_cpu_to_le16(ACTION_SET);
            cmd_buf->CmdCode = HostCmd_CMD_802_11D_DOMAIN_INFO;
            cmd_buf->Domain.Tag = uap_cpu_to_le16(TLV_TYPE_DOMAIN);
            cmd_buf->Domain.Length = uap_cpu_to_le16(sizeof(domain_param_t)
                                                     - BUF_HEADER_SIZE
                                                     +
                                                     (no_of_sub_band *
                                                      sizeof
                                                      (IEEEtypes_SubbandSet_t)));

            memset(cmd_buf->Domain.CountryCode, ' ',
                   sizeof(cmd_buf->Domain.CountryCode));
            memcpy(cmd_buf->Domain.CountryCode, country_80211d,
                   strlen(country_80211d));
            memcpy(cmd_buf->Domain.Subband, sub_bands,
                   no_of_sub_band * sizeof(IEEEtypes_SubbandSet_t));

            /* Send the command */
            uap_ioctl((u8 *) cmd_buf, &cmdlen, buf_len);
            if (buf)
                free(buf);
        }

        /* Check for beginning of AP MAC address filter configurations */
        if (strcmp(args[0], "ap_mac_filter") == 0) {
            is_ap_mac_filter = 1;
            cmd_len =
                sizeof(APCMDBUF_SYS_CONFIGURE) +
                sizeof(TLVBUF_STA_MAC_ADDR_FILTER) +
                (MAX_MAC_ONESHOT_FILTER * ETH_ALEN);
            if (buffer) {
                free(buffer);
                buffer = NULL;
            }
            buffer = (u8 *) malloc(cmd_len);
            if (!buffer) {
                printf("ERR:Cannot allocate memory!\n");
                goto done;
            }
            cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
            cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
            cmd_buf->Size = cmd_len;
            cmd_buf->SeqNum = 0;
            cmd_buf->Result = 0;
            cmd_buf->Action = ACTION_SET;
            filter_tlv =
                (TLVBUF_STA_MAC_ADDR_FILTER *) (buffer +
                                                sizeof(APCMDBUF_SYS_CONFIGURE));
            filter_tlv->Tag = MRVL_STA_MAC_ADDR_FILTER_TLV_ID;
            filter_tlv->Length = 2;
            filter_tlv->Count = 0;
            filter_mac_count = 0;
            continue;
        }

        /* Check for beginning of custom IE configurations */
        if (strcmp(args[0], "custom_ie_config") == 0) {
            is_custom_ie_config = 1;
            cmd_len = sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(tlvbuf_custom_ie)
                +
                ((MAX_IE_BUFFER_LEN + sizeof(custom_ie)) * MAX_CUSTOM_IE_COUNT);
            if (buffer) {
                free(buffer);
                buffer = NULL;
            }
            buffer = (u8 *) malloc(cmd_len);
            if (!buffer) {
                printf("ERR:Cannot allocate memory!\n");
                goto done;
            }
            cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
            cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
            cmd_buf->Size = cmd_len;
            cmd_buf->SeqNum = 0;
            cmd_buf->Result = 0;
            cmd_buf->Action = ACTION_SET;
            custom_ie_tlv =
                (tlvbuf_custom_ie *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));
            custom_ie_ptr = (custom_ie *) (custom_ie_tlv->ie_data);
            custom_ie_tlv_head = custom_ie_tlv;
            custom_ie_tlv_head->Tag = MRVL_MGMT_IE_LIST_TLV_ID;
            continue;
        }

        if ((strcmp(args[0], "FilterMode") == 0) && is_ap_mac_filter) {
            if ((ISDIGIT(args[1]) == 0) || (atoi(args[1]) < 0) ||
                (atoi(args[1]) > 2)) {
                printf
                    ("ERR:Illegal FilterMode paramter %d. Must be either '0', '1', or '2'.\n",
                     atoi(args[1]));
                goto done;
            }
            filter_tlv->FilterMode = atoi(args[1]);
            continue;
        }
        if ((strcmp(args[0], "Count") == 0) && is_ap_mac_filter) {
            filter_tlv->Count = atoi(args[1]);
            if ((ISDIGIT(args[1]) == 0) ||
                (filter_tlv->Count > MAX_MAC_ONESHOT_FILTER)) {
                printf("ERR: Illegal Count parameter.\n");
                goto done;
            }
        }
        if ((strncmp(args[0], "mac_", 4) == 0) && is_ap_mac_filter) {
            if (filter_mac_count < MAX_MAC_ONESHOT_FILTER) {
                if (mac2raw
                    (args[1],
                     &filter_tlv->MacAddress[filter_mac_count * ETH_ALEN]) !=
                    UAP_SUCCESS) {
                    printf("ERR: Invalid MAC address %s \n", args[1]);
                    goto done;
                }
                filter_mac_count++;
            } else {
                printf
                    ("ERR: Filter table can not have more than %d MAC addresses\n",
                     MAX_MAC_ONESHOT_FILTER);
                goto done;
            }
        }

        /* custom ie configuration parameters */
        if ((strncmp(args[0], "MgmtSubtypeMask_", 16) == 0) &&
            is_custom_ie_config) {
            if (UAP_FAILURE == ishexstring(args[1])) {
                printf("ERR:Illegal MgmtSubtypeMask %s.\n", args[1]);
                goto done;
            }
            mask_ie_index = (u16) atoi(args[0] + strlen("MgmtSubtypeMask_"));
            if (mask_ie_index > 3) {
                printf("ERR:Incorrect index %d.\n", mask_ie_index);
                goto done;
            }
            custom_ie_ptr->ie_index = uap_cpu_to_le16(mask_ie_index);
            custom_ie_ptr->mgmt_subtype_mask = (u16) A2HEXDECIMAL(args[1]);
            custom_ie_ptr->mgmt_subtype_mask = uap_cpu_to_le16
                (custom_ie_ptr->mgmt_subtype_mask);
            custom_mask_count++;
            continue;
        }
        if ((strncmp(args[0], "IEBuffer_", 9) == 0) && is_custom_ie_config) {
            if (UAP_FAILURE == ishexstring(args[1])) {
                printf("ERR:Only hex digits are allowed\n");
                goto done;
            }
            ie_buf_len = strlen(args[1]);
            if (!strncasecmp("0x", args[1], 2)) {
                ie_len = (ie_buf_len - 2 + 1) / 2;
                args[1] += 2;
            } else
                ie_len = (ie_buf_len + 1) / 2;

            if (ie_len > MAX_IE_BUFFER_LEN) {
                printf("ERR:Incorrect IE length %d\n", ie_buf_len);
                goto done;
            }

            custom_ie_ptr->ie_index = (u16) atoi(args[0] + strlen("IEBuffer_"));
            if (custom_ie_ptr->ie_index != mask_ie_index) {
                printf("ERR:IE buffer%d should follow MgmtSubtypeMask%d\n",
                       mask_ie_index, mask_ie_index);
                goto done;
            }
            custom_ie_ptr->ie_index = uap_cpu_to_le16(custom_ie_ptr->ie_index);
            string2raw(args[1], custom_ie_ptr->ie_buffer);
            custom_ie_ptr->ie_length = uap_cpu_to_le16(ie_len);
            custom_ie_tlv_len += sizeof(custom_ie) + ie_len;
            custom_ie_tlv = (tlvbuf_custom_ie *) ((u8 *) custom_ie_tlv
                                                  + sizeof(custom_ie) + ie_len);
            custom_ie_ptr = (custom_ie *) (custom_ie_tlv->ie_data);
            custom_buf_count++;
            continue;
        }
        if (strcmp(args[0], "SSID") == 0) {
            if (arg_num == 1) {
                printf("ERR:SSID field is blank!\n");
                goto done;
            } else {
                TLVBUF_SSID *tlv = NULL;
                if (args[1][0] == '"') {
                    args[1]++;
                }
                if (args[1][strlen(args[1]) - 1] == '"') {
                    args[1][strlen(args[1]) - 1] = '\0';
                }
                if ((strlen(args[1]) > MAX_SSID_LENGTH) ||
                    (strlen(args[1]) == 0)) {
                    printf("ERR:SSID length out of range (%d to %d).\n",
                           MIN_SSID_LENGTH, MAX_SSID_LENGTH);
                    goto done;
                }
                /* Append a new TLV */
                tlv_len = sizeof(TLVBUF_SSID) + strlen(args[1]);
                buffer = realloc(buffer, cmd_len + tlv_len);
                if (!buffer) {
                    printf("ERR:Cannot realloc SSID TLV!\n");
                    goto done;
                }
                cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
                tlv = (TLVBUF_SSID *) (buffer + cmd_len);
                cmd_len += tlv_len;
                /* Set TLV fields */
                tlv->Tag = MRVL_SSID_TLV_ID;
                tlv->Length = strlen(args[1]);
                memcpy(tlv->Ssid, args[1], tlv->Length);
                endian_convert_tlv_header_out(tlv);
            }
        }
        if (strcmp(args[0], "BeaconPeriod") == 0) {
            if (is_input_valid(BEACONPERIOD, arg_num - 1, args + 1) !=
                UAP_SUCCESS) {
                goto done;
            }
            TLVBUF_BEACON_PERIOD *tlv = NULL;
            /* Append a new TLV */
            tlv_len = sizeof(TLVBUF_BEACON_PERIOD);
            buffer = realloc(buffer, cmd_len + tlv_len);
            if (!buffer) {
                printf("ERR:Cannot realloc beacon period TLV!\n");
                goto done;
            }
            cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
            tlv = (TLVBUF_BEACON_PERIOD *) (buffer + cmd_len);
            cmd_len += tlv_len;
            /* Set TLV fields */
            tlv->Tag = MRVL_BEACON_PERIOD_TLV_ID;
            tlv->Length = 2;
            tlv->BeaconPeriod_ms = (u16) atoi(args[1]);
            endian_convert_tlv_header_out(tlv);
            tlv->BeaconPeriod_ms = uap_cpu_to_le16(tlv->BeaconPeriod_ms);
        }
        if (strcmp(args[0], "ChanList") == 0) {
            if (is_input_valid(SCANCHANNELS, arg_num - 1, args + 1) !=
                UAP_SUCCESS) {
                goto done;
            }

            TLVBUF_CHANNEL_LIST *tlv = NULL;
            CHANNEL_LIST *pChanList = NULL;
            /* Append a new TLV */
            tlv_len =
                sizeof(TLVBUF_CHANNEL_LIST) +
                ((arg_num - 1) * sizeof(CHANNEL_LIST));
            buffer = realloc(buffer, cmd_len + tlv_len);
            if (!buffer) {
                printf("ERR:Cannot append channel list TLV!\n");
                goto done;
            }
            cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
            tlv = (TLVBUF_CHANNEL_LIST *) (buffer + cmd_len);
            cmd_len += tlv_len;
            /* Set TLV fields */
            tlv->Tag = MRVL_CHANNELLIST_TLV_ID;
            tlv->Length = sizeof(CHANNEL_LIST) * (arg_num - 1);
            pChanList = (CHANNEL_LIST *) tlv->ChanList;
            for (i = 0; i < (arg_num - 1); i++) {
                pChanList->ChanNumber = (u8) atoi(args[i + 1]);
                pChanList->BandConfigType = 0;
                pChanList++;
            }
            endian_convert_tlv_header_out(tlv);
        }
        if (strcmp(args[0], "Channel") == 0) {
            if (is_input_valid(CHANNEL, arg_num - 1, args + 1) != UAP_SUCCESS) {
                goto done;
            }
            TLVBUF_CHANNEL_CONFIG *tlv = NULL;
            /* Append a new TLV */
            tlv_len = sizeof(TLVBUF_CHANNEL_CONFIG);
            buffer = realloc(buffer, cmd_len + tlv_len);
            if (!buffer) {
                printf("ERR:Cannot append channel TLV!\n");
                goto done;
            }
            cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
            tlv = (TLVBUF_CHANNEL_CONFIG *) (buffer + cmd_len);
            cmd_len += tlv_len;
            /* Set TLV fields */
            tlv->Tag = MRVL_CHANNELCONFIG_TLV_ID;
            tlv->Length = 2;
            tlv->ChanNumber = (u8) atoi(args[1]);
            if ((arg_num - 1) == 2)
                tlv->BandConfigType = atoi(args[2]) ? BAND_CONFIG_ACS_MODE : 0;
            else
                tlv->BandConfigType = 0;
            endian_convert_tlv_header_out(tlv);
        }
        if (strcmp(args[0], "AP_MAC") == 0) {
            int ret;
            TLVBUF_AP_MAC_ADDRESS *tlv = NULL;
            /* Append a new TLV */
            tlv_len = sizeof(TLVBUF_AP_MAC_ADDRESS);
            buffer = realloc(buffer, cmd_len + tlv_len);
            if (!buffer) {
                printf("ERR:Cannot append channel TLV!\n");
                goto done;
            }
            cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
            tlv = (TLVBUF_AP_MAC_ADDRESS *) (buffer + cmd_len);
            cmd_len += tlv_len;
            cmd_buf->Action = ACTION_SET;
            tlv->Tag = MRVL_AP_MAC_ADDRESS_TLV_ID;
            tlv->Length = ETH_ALEN;
            if ((ret = mac2raw(args[1], tlv->ApMacAddr)) != UAP_SUCCESS) {
                printf("ERR: %s Address \n",
                       ret == UAP_FAILURE ? "Invalid MAC" : ret ==
                       UAP_RET_MAC_BROADCAST ? "Broadcast" : "Multicast");
                goto done;
            }
            endian_convert_tlv_header_out(tlv);
        }

        if (strcmp(args[0], "RxAntenna") == 0) {
            if ((ISDIGIT(args[1]) != UAP_SUCCESS) || (atoi(args[1]) < 0) ||
                (atoi(args[1]) > 1)) {
                printf("ERR: Invalid Antenna value\n");
                goto done;
            }
            TLVBUF_ANTENNA_CTL *tlv = NULL;
            /* Append a new TLV */
            tlv_len = sizeof(TLVBUF_ANTENNA_CTL);
            buffer = realloc(buffer, cmd_len + tlv_len);
            if (!buffer) {
                printf("ERR:Cannot append channel TLV!\n");
                goto done;
            }
            cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
            tlv = (TLVBUF_ANTENNA_CTL *) (buffer + cmd_len);
            cmd_len += tlv_len;
            cmd_buf->Action = ACTION_SET;
            tlv->Tag = MRVL_ANTENNA_CTL_TLV_ID;
            tlv->Length = 2;
            tlv->WhichAntenna = 0;
            tlv->AntennaMode = atoi(args[1]);
            endian_convert_tlv_header_out(tlv);
        }

        if (strcmp(args[0], "TxAntenna") == 0) {
            if ((ISDIGIT(args[1]) != UAP_SUCCESS) || (atoi(args[1]) < 0) ||
                (atoi(args[1]) > 1)) {
                printf("ERR: Invalid Antenna value\n");
                goto done;
            }
            TLVBUF_ANTENNA_CTL *tlv = NULL;
            /* Append a new TLV */
            tlv_len = sizeof(TLVBUF_ANTENNA_CTL);
            buffer = realloc(buffer, cmd_len + tlv_len);
            if (!buffer) {
                printf("ERR:Cannot append channel TLV!\n");
                goto done;
            }
            cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
            tlv = (TLVBUF_ANTENNA_CTL *) (buffer + cmd_len);
            cmd_len += tlv_len;
            cmd_buf->Action = ACTION_SET;
            tlv->Tag = MRVL_ANTENNA_CTL_TLV_ID;
            tlv->Length = 2;
            tlv->WhichAntenna = 1;
            tlv->AntennaMode = atoi(args[1]);
            endian_convert_tlv_header_out(tlv);
        }
        if (strcmp(args[0], "Rate") == 0) {
            if (is_input_valid(RATE, arg_num - 1, args + 1) != UAP_SUCCESS) {
                printf("ERR: Invalid Rate input\n");
                goto done;
            }
            TLVBUF_RATES *tlv = NULL;
            /* Append a new TLV */
            tlv_len = sizeof(TLVBUF_RATES) + arg_num - 1;
            buffer = realloc(buffer, cmd_len + tlv_len);
            if (!buffer) {
                printf("ERR:Cannot append rates TLV!\n");
                goto done;
            }
            cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
            tlv = (TLVBUF_RATES *) (buffer + cmd_len);
            cmd_len += tlv_len;
            /* Set TLV fields */
            tlv->Tag = MRVL_RATES_TLV_ID;
            tlv->Length = arg_num - 1;
            for (i = 0; i < tlv->Length; i++) {
                rate[i] = tlv->OperationalRates[i] =
                    (u8) A2HEXDECIMAL(args[i + 1]);
            }
            endian_convert_tlv_header_out(tlv);
        }
        if (strcmp(args[0], "TxPowerLevel") == 0) {
            if (is_input_valid(TXPOWER, arg_num - 1, args + 1) != UAP_SUCCESS) {
                printf("ERR:Invalid TxPowerLevel \n");
                goto done;
            } else {
                TLVBUF_TX_POWER *tlv = NULL;
                /* Append a new TLV */
                tlv_len = sizeof(TLVBUF_TX_POWER);
                buffer = realloc(buffer, cmd_len + tlv_len);
                if (!buffer) {
                    printf("ERR:Cannot append tx power level TLV!\n");
                    goto done;
                }
                cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
                tlv = (TLVBUF_TX_POWER *) (buffer + cmd_len);
                cmd_len += tlv_len;
                /* Set TLV fields */
                tlv->Tag = MRVL_TX_POWER_TLV_ID;
                tlv->Length = 1;
                tlv->TxPower_dBm = (u8) atoi(args[1]);
                endian_convert_tlv_header_out(tlv);
            }
        }
        if (strcmp(args[0], "BroadcastSSID") == 0) {
            if (is_input_valid(BROADCASTSSID, arg_num - 1, args + 1) !=
                UAP_SUCCESS) {
                goto done;
            }
            TLVBUF_BCAST_SSID_CTL *tlv = NULL;
            /* Append a new TLV */
            tlv_len = sizeof(TLVBUF_BCAST_SSID_CTL);
            buffer = realloc(buffer, cmd_len + tlv_len);
            if (!buffer) {
                printf("ERR:Cannot append SSID broadcast control TLV!\n");
                goto done;
            }
            cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
            tlv = (TLVBUF_BCAST_SSID_CTL *) (buffer + cmd_len);
            cmd_len += tlv_len;
            /* Set TLV fields */
            tlv->Tag = MRVL_BCAST_SSID_CTL_TLV_ID;
            tlv->Length = 1;
            tlv->BcastSsidCtl = (u8) atoi(args[1]);
            endian_convert_tlv_header_out(tlv);
        }
        if (strcmp(args[0], "RTSThreshold") == 0) {
            if (is_input_valid(RTSTHRESH, arg_num - 1, args + 1) != UAP_SUCCESS) {
                goto done;
            }
            TLVBUF_RTS_THRESHOLD *tlv = NULL;
            /* Append a new TLV */
            tlv_len = sizeof(TLVBUF_RTS_THRESHOLD);
            buffer = realloc(buffer, cmd_len + tlv_len);
            if (!buffer) {
                printf("ERR:Cannot append RTS threshold TLV!\n");
                goto done;
            }
            cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
            tlv = (TLVBUF_RTS_THRESHOLD *) (buffer + cmd_len);
            cmd_len += tlv_len;
            /* Set TLV fields */
            tlv->Tag = MRVL_RTS_THRESHOLD_TLV_ID;
            tlv->Length = 2;
            tlv->RtsThreshold = (u16) atoi(args[1]);
            endian_convert_tlv_header_out(tlv);
            tlv->RtsThreshold = uap_cpu_to_le16(tlv->RtsThreshold);
        }
        if (strcmp(args[0], "FragThreshold") == 0) {
            if (is_input_valid(FRAGTHRESH, arg_num - 1, args + 1) !=
                UAP_SUCCESS) {
                goto done;
            }
            TLVBUF_FRAG_THRESHOLD *tlv = NULL;
            /* Append a new TLV */
            tlv_len = sizeof(TLVBUF_FRAG_THRESHOLD);
            buffer = realloc(buffer, cmd_len + tlv_len);
            if (!buffer) {
                printf("ERR:Cannot append Fragmentation threshold TLV!\n");
                goto done;
            }
            cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
            tlv = (TLVBUF_FRAG_THRESHOLD *) (buffer + cmd_len);
            cmd_len += tlv_len;
            /* Set TLV fields */
            tlv->Tag = MRVL_FRAG_THRESHOLD_TLV_ID;
            tlv->Length = 2;
            tlv->FragThreshold = (u16) atoi(args[1]);
            endian_convert_tlv_header_out(tlv);
            tlv->FragThreshold = uap_cpu_to_le16(tlv->FragThreshold);
        }
        if (strcmp(args[0], "DTIMPeriod") == 0) {
            if (is_input_valid(DTIMPERIOD, arg_num - 1, args + 1) !=
                UAP_SUCCESS) {
                goto done;
            }
            TLVBUF_DTIM_PERIOD *tlv = NULL;
            /* Append a new TLV */
            tlv_len = sizeof(TLVBUF_DTIM_PERIOD);
            buffer = realloc(buffer, cmd_len + tlv_len);
            if (!buffer) {
                printf("ERR:Cannot append DTIM period TLV!\n");
                goto done;
            }
            cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
            tlv = (TLVBUF_DTIM_PERIOD *) (buffer + cmd_len);
            cmd_len += tlv_len;
            /* Set TLV fields */
            tlv->Tag = MRVL_DTIM_PERIOD_TLV_ID;
            tlv->Length = 1;
            tlv->DtimPeriod = (u8) atoi(args[1]);
            endian_convert_tlv_header_out(tlv);
        }
        if (strcmp(args[0], "RadioControl") == 0) {
            if (is_input_valid(RADIOCONTROL, arg_num - 1, args + 1) !=
                UAP_SUCCESS) {
                goto done;
            }
            TLVBUF_RADIO_CTL *tlv = NULL;
            /* Append a new TLV */
            tlv_len = sizeof(TLVBUF_RADIO_CTL);
            buffer = realloc(buffer, cmd_len + tlv_len);
            if (!buffer) {
                printf("ERR:Cannot append radio control TLV!\n");
                goto done;
            }
            cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
            tlv = (TLVBUF_RADIO_CTL *) (buffer + cmd_len);
            cmd_len += tlv_len;
            /* Set TLV fields */
            tlv->Tag = MRVL_RADIO_CTL_TLV_ID;
            tlv->Length = 1;
            tlv->RadioCtl = (u8) atoi(args[1]);
            endian_convert_tlv_header_out(tlv);
        }
        if (strcmp(args[0], "RSNReplayProtection") == 0) {
            if (is_input_valid(RSNREPLAYPROT, arg_num - 1, args + 1) !=
                UAP_SUCCESS) {
                goto done;
            }
            tlvbuf_rsn_replay_prot *tlv = NULL;
            /* Append a new TLV */
            tlv_len = sizeof(tlvbuf_rsn_replay_prot);
            buffer = realloc(buffer, cmd_len + tlv_len);
            if (!buffer) {
                printf("ERR:Cannot append RSN replay protection TLV!\n");
                goto done;
            }
            cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
            tlv = (tlvbuf_rsn_replay_prot *) (buffer + cmd_len);
            cmd_len += tlv_len;
            /* Set TLV fields */
            tlv->Tag = MRVL_RSN_REPLAY_PROT_TLV_ID;
            tlv->Length = 1;
            tlv->rsn_replay_prot = (u8) atoi(args[1]);
            endian_convert_tlv_header_out(tlv);
        }
        if (strcmp(args[0], "TxDataRate") == 0) {
            if (is_input_valid(TXDATARATE, arg_num - 1, args + 1) !=
                UAP_SUCCESS) {
                goto done;
            }
            tx_data_rate = (u16) A2HEXDECIMAL(args[1]);
        }
        if (strcmp(args[0], "MCBCdataRate") == 0) {
            if (is_input_valid(MCBCDATARATE, arg_num - 1, args + 1) !=
                UAP_SUCCESS) {
                goto done;
            }
            mcbc_data_rate = (u16) A2HEXDECIMAL(args[1]);
        }
        if (strcmp(args[0], "PktFwdCtl") == 0) {
            if (is_input_valid(PKTFWD, arg_num - 1, args + 1) != UAP_SUCCESS) {
                goto done;
            }
            TLVBUF_PKT_FWD_CTL *tlv = NULL;
            /* Append a new TLV */
            tlv_len = sizeof(TLVBUF_PKT_FWD_CTL);
            buffer = realloc(buffer, cmd_len + tlv_len);
            if (!buffer) {
                printf("ERR:Cannot append packet forwarding control TLV!\n");
                goto done;
            }
            cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
            tlv = (TLVBUF_PKT_FWD_CTL *) (buffer + cmd_len);
            cmd_len += tlv_len;
            /* Set TLV fields */
            tlv->Tag = MRVL_PKT_FWD_CTL_TLV_ID;
            tlv->Length = 1;
            tlv->PktFwdCtl = (u8) atoi(args[1]);
            endian_convert_tlv_header_out(tlv);
        }
        if (strcmp(args[0], "StaAgeoutTimer") == 0) {
            if (is_input_valid(STAAGEOUTTIMER, arg_num - 1, args + 1) !=
                UAP_SUCCESS) {
                goto done;
            }
            TLVBUF_STA_AGEOUT_TIMER *tlv = NULL;
            /* Append a new TLV */
            tlv_len = sizeof(TLVBUF_STA_AGEOUT_TIMER);
            buffer = realloc(buffer, cmd_len + tlv_len);
            if (!buffer) {
                printf("ERR:Cannot append STA ageout timer TLV!\n");
                goto done;
            }
            cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
            tlv = (TLVBUF_STA_AGEOUT_TIMER *) (buffer + cmd_len);
            cmd_len += tlv_len;
            /* Set TLV fields */
            tlv->Tag = MRVL_STA_AGEOUT_TIMER_TLV_ID;
            tlv->Length = 4;
            tlv->StaAgeoutTimer_ms = (u32) atoi(args[1]);
            endian_convert_tlv_header_out(tlv);
            tlv->StaAgeoutTimer_ms = uap_cpu_to_le32(tlv->StaAgeoutTimer_ms);
        }
        if (strcmp(args[0], "AuthMode") == 0) {
            if (is_input_valid(AUTHMODE, arg_num - 1, args + 1) != UAP_SUCCESS) {
                goto done;
            }
            TLVBUF_AUTH_MODE *tlv = NULL;
            if ((atoi(args[1]) < 0) || (atoi(args[1]) > 1)) {
                printf
                    ("ERR:Illegal AuthMode parameter. Must be either '0' or '1'.\n");
                goto done;
            }
            /* Append a new TLV */
            tlv_len = sizeof(TLVBUF_AUTH_MODE);
            buffer = realloc(buffer, cmd_len + tlv_len);
            if (!buffer) {
                printf("ERR:Cannot append auth mode TLV!\n");
                goto done;
            }
            cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
            tlv = (TLVBUF_AUTH_MODE *) (buffer + cmd_len);
            cmd_len += tlv_len;
            /* Set TLV fields */
            tlv->Tag = MRVL_AUTH_TLV_ID;
            tlv->Length = 1;
            tlv->AuthMode = (u8) atoi(args[1]);
            endian_convert_tlv_header_out(tlv);
        }
        if (strcmp(args[0], "KeyIndex") == 0) {
            if (arg_num == 1) {
                printf("KeyIndex is blank!\n");
                goto done;
            } else {
                if (ISDIGIT(args[1]) == 0) {
                    printf
                        ("ERR:Illegal KeyIndex parameter. Must be either '0', '1', '2', or '3'.\n");
                    goto done;
                }
                keyindex = atoi(args[1]);
                if ((keyindex < 0) || (keyindex > 3)) {
                    printf
                        ("ERR:Illegal KeyIndex parameter. Must be either '0', '1', '2', or '3'.\n");
                    goto done;
                }
            }
        }
        if (strncmp(args[0], "Key_", 4) == 0) {
            if (arg_num == 1) {
                printf("ERR:%s is blank!\n", args[0]);
                goto done;
            } else {
                TLVBUF_WEP_KEY *tlv = NULL;
                int key_len = 0;
                if (args[1][0] == '"') {
                    if ((strlen(args[1]) != 2) && (strlen(args[1]) != 7) &&
                        (strlen(args[1]) != 15)) {
                        printf("ERR:Wrong key length!\n");
                        goto done;
                    }
                    key_len = strlen(args[1]) - 2;
                } else {
                    if ((strlen(args[1]) != 0) && (strlen(args[1]) != 10) &&
                        (strlen(args[1]) != 26)) {
                        printf("ERR:Wrong key length!\n");
                        goto done;
                    }
                    if (UAP_FAILURE == ishexstring(args[1])) {
                        printf
                            ("ERR:Only hex digits are allowed when key length is 10 or 26\n");
                        goto done;
                    }
                    key_len = strlen(args[1]) / 2;
                }
                /* Append a new TLV */
                tlv_len = sizeof(TLVBUF_WEP_KEY) + key_len;
                buffer = realloc(buffer, cmd_len + tlv_len);
                if (!buffer) {
                    printf("ERR:Cannot append WEP key configurations TLV!\n");
                    goto done;
                }
                cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
                tlv = (TLVBUF_WEP_KEY *) (buffer + cmd_len);
                cmd_len += tlv_len;
                /* Set TLV fields */
                tlv->Tag = MRVL_WEP_KEY_TLV_ID;
                tlv->Length = key_len + 2;
                if (strcmp(args[0], "Key_0") == 0) {
                    tlv->KeyIndex = 0;
                } else if (strcmp(args[0], "Key_1") == 0) {
                    tlv->KeyIndex = 1;
                } else if (strcmp(args[0], "Key_2") == 0) {
                    tlv->KeyIndex = 2;
                } else if (strcmp(args[0], "Key_3") == 0) {
                    tlv->KeyIndex = 3;
                }
                if (keyindex == tlv->KeyIndex) {
                    tlv->IsDefault = 1;
                } else {
                    tlv->IsDefault = 0;
                }
                if (args[1][0] == '"') {
                    memcpy(tlv->Key, &args[1][1], strlen(args[1]) - 2);
                } else {
                    string2raw(args[1], tlv->Key);
                }
                endian_convert_tlv_header_out(tlv);
            }
        }
        if (strcmp(args[0], "PSK") == 0) {
            if (arg_num == 1) {
                printf("ERR:PSK is blank!\n");
                goto done;
            } else {
                TLVBUF_WPA_PASSPHRASE *tlv = NULL;
                if (args[1][0] == '"') {
                    args[1]++;
                }
                if (args[1][strlen(args[1]) - 1] == '"') {
                    args[1][strlen(args[1]) - 1] = '\0';
                }
                tlv_len = sizeof(TLVBUF_WPA_PASSPHRASE) + strlen(args[1]);
                if (strlen(args[1]) > MAX_WPA_PASSPHRASE_LENGTH) {
                    printf("ERR:PSK too long.\n");
                    goto done;
                }
                if (strlen(args[1]) < MIN_WPA_PASSPHRASE_LENGTH) {
                    printf("ERR:PSK too short.\n");
                    goto done;
                }
                if (strlen(args[1]) == MAX_WPA_PASSPHRASE_LENGTH) {
                    if (UAP_FAILURE == ishexstring(args[1])) {
                        printf
                            ("ERR:Only hex digits are allowed when passphrase's length is 64\n");
                        goto done;
                    }
                }
                /* Append a new TLV */
                buffer = realloc(buffer, cmd_len + tlv_len);
                if (!buffer) {
                    printf("ERR:Cannot append WPA passphrase TLV!\n");
                    goto done;
                }
                cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
                tlv = (TLVBUF_WPA_PASSPHRASE *) (buffer + cmd_len);
                cmd_len += tlv_len;
                /* Set TLV fields */
                tlv->Tag = MRVL_WPA_PASSPHRASE_TLV_ID;
                tlv->Length = strlen(args[1]);
                memcpy(tlv->Passphrase, args[1], tlv->Length);
                endian_convert_tlv_header_out(tlv);
            }
        }
        if (strcmp(args[0], "Protocol") == 0) {
            if (is_input_valid(PROTOCOL, arg_num - 1, args + 1) != UAP_SUCCESS) {
                goto done;
            }
            TLVBUF_PROTOCOL *tlv = NULL;
            /* Append a new TLV */
            tlv_len = sizeof(TLVBUF_PROTOCOL);
            buffer = realloc(buffer, cmd_len + tlv_len);
            if (!buffer) {
                printf("ERR:Cannot append protocol TLV!\n");
                goto done;
            }
            cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
            tlv = (TLVBUF_PROTOCOL *) (buffer + cmd_len);
            cmd_len += tlv_len;
            /* Set TLV fields */
            tlv->Tag = MRVL_PROTOCOL_TLV_ID;
            tlv->Length = 2;
            tlv->Protocol = (u16) atoi(args[1]);
            endian_convert_tlv_header_out(tlv);
            tlv->Protocol = uap_cpu_to_le16(tlv->Protocol);
            if (atoi(args[1]) & (PROTOCOL_WPA | PROTOCOL_WPA2)) {
                TLVBUF_AKMP *tlv = NULL;
                /* Append a new TLV */
                tlv_len = sizeof(TLVBUF_AKMP);
                buffer = realloc(buffer, cmd_len + tlv_len);
                if (!buffer) {
                    printf("ERR:Cannot append AKMP TLV!\n");
                    goto done;
                }
                cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
                tlv = (TLVBUF_AKMP *) (buffer + cmd_len);
                cmd_len += tlv_len;
                /* Set TLV fields */
                tlv->Tag = MRVL_AKMP_TLV_ID;
                tlv->Length = 2;
                tlv->KeyMgmt = KEY_MGMT_PSK;
                endian_convert_tlv_header_out(tlv);
                tlv->KeyMgmt = uap_cpu_to_le16(tlv->KeyMgmt);
            }
        }
        if (strcmp(args[0], "PairwiseCipher") == 0) {
            if (arg_num == 1) {
                printf("ERR:PairwiseCipher is blank!\n");
                goto done;
            } else {
                if (ISDIGIT(args[1]) == 0) {
                    printf
                        ("ERR:Illegal PairwiseCipher parameter. Must be either bit '2' or '3'.\n");
                    goto done;
                }
                pairwisecipher = atoi(args[1]);
                if (pairwisecipher & ~CIPHER_BITMAP) {
                    printf
                        ("ERR:Illegal PairwiseCipher parameter. Must be either bit '2' or '3'.\n");
                    goto done;
                }
            }
        }
        if (strcmp(args[0], "GroupCipher") == 0) {
            if (arg_num == 1) {
                printf("ERR:GroupCipher is blank!\n");
                goto done;
            } else {
                if (ISDIGIT(args[1]) == 0) {
                    printf
                        ("ERR:Illegal GroupCipher parameter. Must be either bit '2' or '3'.\n");
                    goto done;
                }
                groupcipher = atoi(args[1]);
                if (groupcipher & ~CIPHER_BITMAP) {
                    printf
                        ("ERR:Illegal GroupCipher parameter. Must be either bit '2' or '3'.\n");
                    goto done;
                }
            }
        }
        if (strcmp(args[0], "GroupRekeyTime") == 0) {
            if (is_input_valid(GROUPREKEYTIMER, arg_num - 1, args + 1) !=
                UAP_SUCCESS) {
                goto done;
            }
            TLVBUF_GROUP_REKEY_TIMER *tlv = NULL;

            /* Append a new TLV */
            tlv_len = sizeof(TLVBUF_GROUP_REKEY_TIMER);
            buffer = realloc(buffer, cmd_len + tlv_len);
            if (!buffer) {
                printf("ERR:Cannot append protocol TLV!\n");
                goto done;
            }
            cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
            tlv = (TLVBUF_GROUP_REKEY_TIMER *) (buffer + cmd_len);
            cmd_len += tlv_len;
            /* Set TLV fields */
            tlv->Tag = MRVL_GRP_REKEY_TIME_TLV_ID;
            tlv->Length = 4;
            tlv->GroupRekeyTime_sec = (u32) atoi(args[1]);
            endian_convert_tlv_header_out(tlv);
            tlv->GroupRekeyTime_sec = uap_cpu_to_le32(tlv->GroupRekeyTime_sec);
        }
        if (strcmp(args[0], "MaxStaNum") == 0) {
            if (is_input_valid(MAXSTANUM, arg_num - 1, args + 1) != UAP_SUCCESS) {
                goto done;
            }
            TLVBUF_MAX_STA_NUM *tlv = NULL;

            /* Append a new TLV */
            tlv_len = sizeof(TLVBUF_MAX_STA_NUM);
            buffer = realloc(buffer, cmd_len + tlv_len);
            if (!buffer) {
                printf("ERR:Cannot realloc max station number TLV!\n");
                goto done;
            }
            cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
            tlv = (TLVBUF_MAX_STA_NUM *) (buffer + cmd_len);
            cmd_len += tlv_len;
            /* Set TLV fields */
            tlv->Tag = MRVL_MAX_STA_CNT_TLV_ID;
            tlv->Length = 2;
            tlv->Max_sta_num = (u16) atoi(args[1]);
            endian_convert_tlv_header_out(tlv);
            tlv->Max_sta_num = uap_cpu_to_le16(tlv->Max_sta_num);
        }
        if (strcmp(args[0], "Retrylimit") == 0) {
            if (is_input_valid(RETRYLIMIT, arg_num - 1, args + 1) !=
                UAP_SUCCESS) {
                goto done;
            }
            TLVBUF_RETRY_LIMIT *tlv = NULL;

            /* Append a new TLV */
            tlv_len = sizeof(TLVBUF_RETRY_LIMIT);
            buffer = realloc(buffer, cmd_len + tlv_len);
            if (!buffer) {
                printf("ERR:Cannot realloc retry limit TLV!\n");
                goto done;
            }
            cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
            tlv = (TLVBUF_RETRY_LIMIT *) (buffer + cmd_len);
            cmd_len += tlv_len;
            /* Set TLV fields */
            tlv->Tag = MRVL_RETRY_LIMIT_TLV_ID;
            tlv->Length = 1;
            tlv->retry_limit = (u8) atoi(args[1]);
            endian_convert_tlv_header_out(tlv);
        }
#if DEBUG
        if (cmd_len != 0) {
            hexdump("Command Buffer", (void *) cmd_buf, cmd_len, ' ');
        }
#endif
    }
  done:
    fclose(config_file);
    if (buffer)
        free(buffer);
    if (line)
        free(line);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index