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

int is_input_valid ( valid_inputs  cmd,
int  argc,
char *  argv[] 
)

Checkes a particular input for validatation.

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

Definition at line 4494 of file uaputl.c.

References A2HEXDECIMAL, BASIC_RATE_SET_BIT, check_mandatory_rates(), has_dup_channel(), has_dup_rate(), IS_HEX_OR_DIGIT, is_protocol_valid(), is_rate_valid(), ISDIGIT(), MAX_BEACON_PERIOD, MAX_CHANNELS, MAX_DTIM_PERIOD, MAX_FRAG_THRESHOLD, MAX_GRP_TIMER, MAX_RATES, MAX_RETRY_LIMIT, MAX_RTS_THRESHOLD, MAX_STAGE_OUT_TIME, MAX_TX_POWER, MIN_BEACON_PERIOD, MIN_FRAG_THRESHOLD, MIN_STAGE_OUT_TIME, MIN_TX_POWER, UAP_FAILURE, and UAP_SUCCESS.

Referenced by apcmd_coex_config_profile(), apcmd_read_eeprom(), apcmd_sys_cfg_auth(), apcmd_sys_cfg_bcast_ssid_ctl(), apcmd_sys_cfg_beacon_period(), apcmd_sys_cfg_channel(), apcmd_sys_cfg_dtim_period(), apcmd_sys_cfg_frag_threshold(), apcmd_sys_cfg_group_rekey_timer(), apcmd_sys_cfg_max_sta_num(), apcmd_sys_cfg_mcbc_data_rate(), apcmd_sys_cfg_pkt_fwd_ctl(), apcmd_sys_cfg_protocol(), apcmd_sys_cfg_radio_ctl(), apcmd_sys_cfg_rates(), apcmd_sys_cfg_rates_ext(), apcmd_sys_cfg_retry_limit(), apcmd_sys_cfg_rsn_replay_prot(), apcmd_sys_cfg_rts_threshold(), apcmd_sys_cfg_scan_channels(), apcmd_sys_cfg_sta_ageout_timer(), apcmd_sys_cfg_tx_data_rate(), apcmd_sys_cfg_tx_power(), and apcmd_sys_config_profile().

{
    int i;
    int ret = UAP_SUCCESS;
    if (argc == 0)
        return UAP_FAILURE;
    switch (cmd) {
    case RDEEPROM:
        if (argc != 2) {
            printf(" ERR: Argument count mismatch\n");
            ret = UAP_FAILURE;
        } else {
            if ((ISDIGIT(argv[0]) == 0) || (ISDIGIT(argv[1]) == 0) ||
                (A2HEXDECIMAL(argv[0]) & 0x03) ||
                (A2HEXDECIMAL(argv[0]) < 0) ||
                (A2HEXDECIMAL(argv[1]) & 0x03) ||
                (A2HEXDECIMAL(argv[1]) < 4) || (A2HEXDECIMAL(argv[1]) > 20)) {
                printf(" ERR: Invalid inputs for Read EEPROM\n");
                ret = UAP_FAILURE;
            }
        }
        break;
    case SCANCHANNELS:
        if (argc > MAX_CHANNELS) {
            printf("ERR: Invalid List of Channels\n");
            ret = UAP_FAILURE;
        } else {
            for (i = 0; i < argc; i++) {
                if ((ISDIGIT(argv[i]) == 0) || (atoi(argv[i]) < 1) ||
                    (atoi(argv[i]) > MAX_CHANNELS)) {
                    printf("ERR: Channel must be in the range of 1 to %d\n",
                           MAX_CHANNELS);
                    ret = UAP_FAILURE;
                    break;
                }
            }
            if ((ret != UAP_FAILURE) &&
                (has_dup_channel(argc, argv) != UAP_SUCCESS)) {
                printf("ERR: Duplicate channel values entered\n");
                ret = UAP_FAILURE;
            }
        }
        break;
    case TXPOWER:
        if ((argc > 1) || (ISDIGIT(argv[0]) == 0)) {
            printf("ERR:Invalid Transmit power\n");
            ret = UAP_FAILURE;
        } else {
            if ((atoi(argv[0]) < MIN_TX_POWER) ||
                (atoi(argv[0]) > MAX_TX_POWER)) {
                printf("ERR: TX Powar must be in the rage of %d to %d. \n",
                       MIN_TX_POWER, MAX_TX_POWER);
                ret = UAP_FAILURE;
            }
        }
        break;
    case PROTOCOL:
        if ((argc > 1) || (ISDIGIT(argv[0]) == 0)) {
            printf("ERR:Invalid Protocol\n");
            ret = UAP_FAILURE;
        } else
            ret = is_protocol_valid(atoi(argv[0]));
        break;
    case CHANNEL:
        if ((argc != 1) && (argc != 2)) {
            printf("ERR: Incorrect arguments for channel.\n");
            ret = UAP_FAILURE;
        } else {
            if (argc == 2) {
                if ((ISDIGIT(argv[1]) == 0) || (atoi(argv[1]) < 0) ||
                    (atoi(argv[1]) > 1)) {
                    printf("ERR: MODE must be either 0 or 1\n");
                    ret = UAP_FAILURE;
                }
                if ((atoi(argv[1]) == 1) && (atoi(argv[0]) != 0)) {
                    printf("ERR: Channel must be 0 for ACS; MODE = 1.\n");
                    ret = UAP_FAILURE;
                }
            }
            if ((argc == 1) || (atoi(argv[1]) == 0)) {
                if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) < 1) ||
                    (atoi(argv[0]) > MAX_CHANNELS)) {
                    printf("ERR: Channel must be in the range of 1 to %d\n",
                           MAX_CHANNELS);
                    ret = UAP_FAILURE;
                }
            }
        }
        break;
    case RATE:
        if (argc > MAX_RATES) {
            printf("ERR: Incorrect number of RATES arguments.\n");
            ret = UAP_FAILURE;
        } else {
            for (i = 0; i < argc; i++) {
                if ((IS_HEX_OR_DIGIT(argv[i]) == UAP_FAILURE) ||
                    (is_rate_valid(A2HEXDECIMAL(argv[i]) & ~BASIC_RATE_SET_BIT)
                     != UAP_SUCCESS)) {
                    printf("ERR:Unsupported rate.\n");
                    ret = UAP_FAILURE;
                    break;
                }
            }
            if ((ret != UAP_FAILURE) &&
                (has_dup_rate(argc, argv) != UAP_SUCCESS)) {
                printf("ERR: Duplicate rate values entered\n");
                ret = UAP_FAILURE;
            }
            if (check_mandatory_rates(argc, argv) != UAP_SUCCESS) {
                ret = UAP_FAILURE;
            }
        }
        break;
    case BROADCASTSSID:
        if (argc != 1) {
            printf("ERR:wrong BROADCASTSSID arguments.\n");
            ret = UAP_FAILURE;
        } else {
            if ((ISDIGIT(argv[0]) == 0) ||
                ((atoi(argv[0]) != 0) && (atoi(argv[0]) != 1))) {
                printf
                    ("ERR:Illegal parameter %s for BROADCASTSSID. Must be either '0' or '1'.\n",
                     argv[0]);
                ret = UAP_FAILURE;
            }
        }
        break;
    case RTSTHRESH:
        if (argc != 1) {
            printf("ERR:Incorrect number of arguments for RTSTHRESHOLD\n");
            ret = UAP_FAILURE;
        } else if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) < 0) ||
                   (atoi(argv[0]) > MAX_RTS_THRESHOLD)) {
            printf
                ("ERR:Illegal RTSTHRESHOLD %s. The value must between 0 and %d\n",
                 argv[0], MAX_RTS_THRESHOLD);
            ret = UAP_FAILURE;
        }
        break;
    case FRAGTHRESH:
        if (argc != 1) {
            printf("ERR:Incorrect number of arguments for FRAGTHRESH\n");
            ret = UAP_FAILURE;
        } else if ((ISDIGIT(argv[0]) == 0) ||
                   (atoi(argv[0]) < MIN_FRAG_THRESHOLD) ||
                   (atoi(argv[0]) > MAX_FRAG_THRESHOLD)) {
            printf
                ("ERR:Illegal FRAGTHRESH %s. The value must between %d and %d\n",
                 argv[0], MIN_FRAG_THRESHOLD, MAX_FRAG_THRESHOLD);
            ret = UAP_FAILURE;
        }
        break;
    case DTIMPERIOD:
        if (argc != 1) {
            printf("ERR:Incorrect number of arguments for DTIMPERIOD\n");
            ret = UAP_FAILURE;
        } else if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) < 1) ||
                   (atoi(argv[0]) > MAX_DTIM_PERIOD)) {
            printf("ERR: DTIMPERIOD Value must be in range of 1 to %d\n",
                   MAX_DTIM_PERIOD);
            ret = UAP_FAILURE;
        }
        break;
    case RADIOCONTROL:
        if (argc != 1) {
            printf("ERR:Incorrect number of arguments for RADIOCONTROL\n");
            ret = UAP_FAILURE;
        } else {
            if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) < 0) ||
                (atoi(argv[0]) > 1)) {
                printf
                    ("ERR:Illegal RADIOCONTROL parameter %s. Must be either '0' or '1'.\n",
                     argv[0]);
                ret = UAP_FAILURE;
            }
        }
        break;
    case RSNREPLAYPROT:
        if (argc != 1) {
            printf("ERR:wrong RSNREPLAYPROT arguments.\n");
            ret = UAP_FAILURE;
        } else {
            if ((ISDIGIT(argv[0]) == 0) ||
                ((atoi(argv[0]) != 0) && (atoi(argv[0]) != 1))) {
                printf
                    ("ERR:Illegal parameter %s for RSNREPLAYPROT. Must be either '0' or '1'.\n",
                     argv[0]);
                ret = UAP_FAILURE;
            }
        }
        break;
    case MCBCDATARATE:
    case TXDATARATE:
        if (argc != 1) {
            printf("ERR:Incorrect number of arguments for DATARATE\n");
            ret = UAP_FAILURE;
        } else {
            if (IS_HEX_OR_DIGIT(argv[0]) == UAP_FAILURE) {
                printf("ERR: invalid data rate\n");
                ret = UAP_FAILURE;
            } else if ((A2HEXDECIMAL(argv[0]) != 0) &&
                       (is_rate_valid
                        (A2HEXDECIMAL(argv[0]) & ~BASIC_RATE_SET_BIT) !=
                        UAP_SUCCESS)) {
                printf("ERR: invalid data rate\n");
                ret = UAP_FAILURE;
            }
        }
        break;
    case PKTFWD:
        if (argc != 1) {
            printf("ERR:Incorrect number of arguments for PKTFWD.\n");
            ret = UAP_FAILURE;
        } else if ((ISDIGIT(argv[0]) == 0) ||
                   ((atoi(argv[0]) != 0) && (atoi(argv[0]) != 1))) {
            printf
                ("ERR:Illegal PKTFWD parameter %s. Must be either '0' or '1'.\n",
                 argv[0]);
            ret = UAP_FAILURE;
        }
        break;
    case STAAGEOUTTIMER:
        if (argc != 1) {
            printf("ERR:Incorrect number of arguments for STAAGEOUTTIMER.\n");
            ret = UAP_FAILURE;
        } else {
            if ((ISDIGIT(argv[0]) == 0) || ((atoi(argv[0]) != 0) &&
                                            ((atoi(argv[0]) <
                                              MIN_STAGE_OUT_TIME) ||
                                             (atoi(argv[0]) >
                                              MAX_STAGE_OUT_TIME)))) {
                printf
                    ("ERR:Illegal STAAGEOUTTIMER %s. Must be between %d and %d.\n",
                     argv[0], MIN_STAGE_OUT_TIME, MAX_STAGE_OUT_TIME);
                ret = UAP_FAILURE;
            }
        }
        break;
    case AUTHMODE:
        if (argc != 1) {
            printf("ERR:Incorrect number of arguments for AUTHMODE\n");
            ret = UAP_FAILURE;
        } else {
            if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) < 0) ||
                (atoi(argv[0]) > 1)) {
                printf
                    ("ERR:Illegal AUTHMODE parameter %s. Must be either '0', or '1'.\n",
                     argv[0]);
                ret = UAP_FAILURE;
            }
        }
        break;
    case GROUPREKEYTIMER:
        if (argc != 1) {
            printf("ERR:Incorrect number of arguments for GROUPREKEYTIMER.\n");
            ret = UAP_FAILURE;
        } else {
            if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) < 0) ||
                (atoi(argv[0]) > MAX_GRP_TIMER)) {
                printf("ERR: GROUPREKEYTIMER range is [0:%d] (0 for disable)\n",
                       MAX_GRP_TIMER);
                ret = UAP_FAILURE;
            }
        }
        break;
    case MAXSTANUM:
        if (argc != 1) {
            printf("ERR:Incorrect number of arguments for MAXSTANUM\n");
            ret = UAP_FAILURE;
        } else {
            if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) > 8) ||
                (atoi(argv[0]) < 0)) {
                printf("ERR:STA_NUM must be in the range of [0:8] %s.\n",
                       argv[0]);
                ret = UAP_FAILURE;
            }
        }
        break;
    case BEACONPERIOD:
        if (argc != 1) {
            printf("ERR:Incorrect number of argument for BEACONPERIOD.\n");
            ret = UAP_FAILURE;
        } else {
            if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) < MIN_BEACON_PERIOD)
                || (atoi(argv[0]) > MAX_BEACON_PERIOD)) {
                printf("ERR: BEACONPERIOD must be in range of %d to %d.\n",
                       MIN_BEACON_PERIOD, MAX_BEACON_PERIOD);
                ret = UAP_FAILURE;
            }
        }
        break;
    case RETRYLIMIT:
        if (argc != 1) {
            printf("ERR:Incorrect number of arguments for RETRY LIMIT\n");
            ret = UAP_FAILURE;
        } else {
            if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) > MAX_RETRY_LIMIT) ||
                (atoi(argv[0]) < 0)) {
                printf
                    ("ERR:RETRY_LIMIT must be in the range of [0:%d]. The  input was %s.\n",
                     MAX_RETRY_LIMIT, argv[0]);
                ret = UAP_FAILURE;
            }
        }
        break;
    case COEX_COMM_BITMAP:
        if (argc != 1) {
            printf("ERR:Incorrect number of arguments for Bitmap.\n");
            ret = UAP_FAILURE;
        } else {
            /* Only bit 0 is supported now, hence check for 1 or 0 */
            if ((IS_HEX_OR_DIGIT(argv[0]) == 0) || (atoi(argv[0]) < 0) ||
                (atoi(argv[0]) > 1)) {
                printf("ERR: Bitmap must have value of 1 or 0.\n");
                ret = UAP_FAILURE;
            }
        }
        break;
    case COEX_SCO_ACL_FREQ:
        if (argc != 1) {
            printf("ERR:Incorrect number of arguments for aclFrequency.\n");
            ret = UAP_FAILURE;
        } else {
            if (ISDIGIT(argv[0]) == 0) {
                printf("ERR: Incorrect value for aclFrequency.\n");
                ret = UAP_FAILURE;
            }
        }
        break;
    case COEX_ACL_ENABLED:
        if (argc != 1) {
            printf("ERR:Incorrect number of arguments for (acl) enabled.\n");
            ret = UAP_FAILURE;
        } else {
            if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) < 0) ||
                (atoi(argv[0]) > 1)) {
                printf("ERR: (acl) enabled must have value of 1 or 0.\n");
                ret = UAP_FAILURE;
            }
        }
        break;
    case COEX_ACL_BT_TIME:
    case COEX_ACL_WLAN_TIME:
        if (argc != 1) {
            printf("ERR:Incorrect number of arguments for bt/wlan time.\n");
            ret = UAP_FAILURE;
        } else {
            if (ISDIGIT(argv[0]) == 0) {
                printf("ERR: Incorrect value for bt/wlan time.\n");
                ret = UAP_FAILURE;
            }
        }
        break;
    case COEX_PROTECTION:
        if (argc != 2) {
            printf("ERR:Incorrect number of arguments for %s.\n", argv[0]);
            ret = UAP_FAILURE;
        } else {
            if (ISDIGIT(argv[1]) == 0) {
                printf("ERR: Incorrect value for %s.\n", argv[0]);
                ret = UAP_FAILURE;
            }
        }
        break;
    default:
        ret = UAP_FAILURE;
        break;
    }
    return ret;
}

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