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

int uap_ioctl ( u8 cmd,
u16 size,
u16  buf_size 
)

Performs the ioctl operation to send the command to the driver.

Parameters:
cmdPointer to the command buffer
sizePointer to the command size. This value is overwritten by the function with the size of the received response.
buf_sizeSize of the allocated command buffer
Returns:
UAP_SUCCESS or UAP_FAILURE

Definition at line 5417 of file uaputl.c.

References APCMD_RESP_CHECK, APCMD_SYS_CONFIGURE, BUF_HEADER_SIZE, dev_name, endian_convert_request_header, endian_convert_response_header, hexdump(), HostCmd_CMD_ID_MASK, uap_cpu_to_le16, UAP_FAILURE, UAP_SUCCESS, and UAPHOSTCMD.

Referenced by apcmd_bss_start(), apcmd_bss_stop(), apcmd_cfg_80211d(), apcmd_cfg_data(), apcmd_coex_config(), apcmd_coex_config_profile(), apcmd_memaccess(), apcmd_read_eeprom(), apcmd_regrdwr_process(), apcmd_sta_deauth(), apcmd_sta_filter_table(), apcmd_sta_list(), apcmd_sys_cfg_antenna_ctl(), apcmd_sys_cfg_ap_mac_address(), apcmd_sys_cfg_auth(), apcmd_sys_cfg_bcast_ssid_ctl(), apcmd_sys_cfg_beacon_period(), apcmd_sys_cfg_channel(), apcmd_sys_cfg_cipher(), apcmd_sys_cfg_custom_ie(), 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_preamble_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_ssid(), apcmd_sys_cfg_sta_ageout_timer(), apcmd_sys_cfg_tx_data_rate(), apcmd_sys_cfg_tx_power(), apcmd_sys_cfg_wep_key(), apcmd_sys_cfg_wpa_passphrase(), apcmd_sys_config(), apcmd_sys_config_profile(), apcmd_sys_debug(), apcmd_sys_info(), apcmd_sys_reset(), apcmd_uap_stats(), get_sys_cfg_rates(), and sg_snmp_mib().

{
    struct ifreq ifr;
    APCMDBUF *header = NULL;
    s32 sockfd;

    if (buf_size < *size) {
        printf("buf_size should not less than cmd buffer size\n");
        return UAP_FAILURE;
    }

    /* Open socket */
    if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
        printf("ERR:Cannot open socket\n");
        return UAP_FAILURE;
    }
    *(u32 *) cmd = buf_size - BUF_HEADER_SIZE;

    /* Initialize the ifr structure */
    memset(&ifr, 0, sizeof(ifr));
    strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, strlen(dev_name));
    ifr.ifr_ifru.ifru_data = (void *) cmd;
    header = (APCMDBUF *) cmd;
    header->Size = *size - BUF_HEADER_SIZE;
    if (header->CmdCode == APCMD_SYS_CONFIGURE) {
        APCMDBUF_SYS_CONFIGURE *sys_cfg;
        sys_cfg = (APCMDBUF_SYS_CONFIGURE *) cmd;
        sys_cfg->Action = uap_cpu_to_le16(sys_cfg->Action);
    }
    endian_convert_request_header(header);
#if DEBUG
    /* Dump request buffer */
    hexdump("Request buffer", (void *) cmd, *size, ' ');
#endif
    /* Perform ioctl */
    errno = 0;
    if (ioctl(sockfd, UAPHOSTCMD, &ifr)) {
        perror("");
        printf("ERR:UAPHOSTCMD is not supported by %s\n", dev_name);
        close(sockfd);
        return UAP_FAILURE;
    }
    endian_convert_response_header(header);
    header->CmdCode &= HostCmd_CMD_ID_MASK;
    header->CmdCode |= APCMD_RESP_CHECK;
    *size = header->Size;

    /* Validate response size */
    if (*size > (buf_size - BUF_HEADER_SIZE)) {
        printf
            ("ERR:Response size (%d) greater than buffer size (%d)! Aborting!\n",
             *size, buf_size);
        close(sockfd);
        return UAP_FAILURE;
    }
#if DEBUG
    /* Dump respond buffer */
    hexdump("Respond buffer", (void *) header, header->Size + BUF_HEADER_SIZE,
            ' ');
#endif

    /* Close socket */
    close(sockfd);
    return UAP_SUCCESS;
}

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