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

int get_sys_cfg_rates ( u8 rates )

get configured operational rates.

Parameters:
ratesOperational rates allowed are stored at this pointer
Returns:
number of basic rates allowed. -1 if a failure

Definition at line 615 of file uapcmd.c.

References ACTION_GET, APCMD_RESP_CHECK, APCMD_SYS_CONFIGURE, CMD_SUCCESS, endian_convert_tlv_header_in, endian_convert_tlv_header_out, MAX_DATA_RATES, MRVL_RATES_TLV_ID, UAP_FAILURE, uap_ioctl(), and UAP_SUCCESS.

Referenced by is_mcbc_rate_valid(), and is_tx_rate_valid().

{
    APCMDBUF_SYS_CONFIGURE *cmd_buf = NULL;
    TLVBUF_RATES *tlv = NULL;
    u8 *buffer = NULL;
    u16 cmd_len;
    int ret = UAP_FAILURE;
    int i = 0;
    int rate_cnt = 0;
    /* Initialize the command length */
    cmd_len =
        sizeof(APCMDBUF_SYS_CONFIGURE) + sizeof(TLVBUF_RATES) + MAX_DATA_RATES;
    /* Initialize the command buffer */
    buffer = (u8 *) malloc(cmd_len);
    if (!buffer) {
        printf("ERR:Cannot allocate buffer for command!\n");
        return -1;
    }
    bzero((char *) buffer, cmd_len);

    /* Locate headers */
    cmd_buf = (APCMDBUF_SYS_CONFIGURE *) buffer;
    tlv = (TLVBUF_RATES *) (buffer + sizeof(APCMDBUF_SYS_CONFIGURE));

    /* Fill the command buffer */
    cmd_buf->CmdCode = APCMD_SYS_CONFIGURE;
    cmd_buf->Size = cmd_len;
    cmd_buf->SeqNum = 0;
    cmd_buf->Result = 0;
    tlv->Tag = MRVL_RATES_TLV_ID;
    cmd_buf->Action = ACTION_GET;
    tlv->Length = MAX_DATA_RATES;

    endian_convert_tlv_header_out(tlv);
    /* Send the command */
    ret = uap_ioctl((u8 *) cmd_buf, &cmd_len, cmd_len);
    endian_convert_tlv_header_in(tlv);
    /* Process response */
    if (ret == UAP_SUCCESS) {
        /* Verify response */
        if ((cmd_buf->CmdCode != (APCMD_SYS_CONFIGURE | APCMD_RESP_CHECK)) ||
            (tlv->Tag != MRVL_RATES_TLV_ID)) {
            printf("ERR:Corrupted response! CmdCode=%x, Tlv->Tag=%x\n",
                   cmd_buf->CmdCode, tlv->Tag);
            free(buffer);
            return -1;
        }

        /* copy response */
        if (cmd_buf->Result == CMD_SUCCESS) {
            for (i = 0; i < tlv->Length; i++) {
                if (tlv->OperationalRates[i] != 0) {
                    rates[rate_cnt++] = tlv->OperationalRates[i];
                }
            }
        } else {
            printf("ERR:Could not get operational rates!\n");
        }
    } else {
        printf("ERR:Command sending failed!\n");
    }
    if (buffer)
        free(buffer);
    return rate_cnt;
}

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