📄 sta_ioctl.c
字号:
{ iwe.u.mode = IW_MODE_INFRA; } else { iwe.u.mode = IW_MODE_AUTO; } iwe.len = IW_EV_UINT_LEN; previous_ev = current_ev; current_ev = IWE_STREAM_ADD_EVENT(info, current_ev, end_buf, &iwe, IW_EV_UINT_LEN); if (current_ev == previous_ev)#if WIRELESS_EXT >= 17 return -E2BIG;#else break;#endif //Channel and Frequency //================================ memset(&iwe, 0, sizeof(iwe)); iwe.cmd = SIOCGIWFREQ; if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter)) iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel; else iwe.u.freq.m = pAdapter->ScanTab.BssEntry[i].Channel; iwe.u.freq.e = 0; iwe.u.freq.i = 0; previous_ev = current_ev; current_ev = IWE_STREAM_ADD_EVENT(info, current_ev,end_buf, &iwe, IW_EV_FREQ_LEN); if (current_ev == previous_ev)#if WIRELESS_EXT >= 17 return -E2BIG;#else break;#endif //Add quality statistics //================================ memset(&iwe, 0, sizeof(iwe)); iwe.cmd = IWEVQUAL; iwe.u.qual.level = 0; iwe.u.qual.noise = 0; set_quality(pAdapter, &iwe.u.qual, pAdapter->ScanTab.BssEntry[i].Rssi); current_ev = IWE_STREAM_ADD_EVENT(info, current_ev, end_buf, &iwe, IW_EV_QUAL_LEN); if (current_ev == previous_ev)#if WIRELESS_EXT >= 17 return -E2BIG;#else break;#endif //Encyption key //================================ memset(&iwe, 0, sizeof(iwe)); iwe.cmd = SIOCGIWENCODE; if (CAP_IS_PRIVACY_ON (pAdapter->ScanTab.BssEntry[i].CapabilityInfo )) iwe.u.data.flags =IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; else iwe.u.data.flags = IW_ENCODE_DISABLED; previous_ev = current_ev; current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf,&iwe, (char *)pAdapter->SharedKey[BSS0][(iwe.u.data.flags & IW_ENCODE_INDEX)-1].Key); if (current_ev == previous_ev)#if WIRELESS_EXT >= 17 return -E2BIG;#else break;#endif //Bit Rate //================================ if (pAdapter->ScanTab.BssEntry[i].SupRateLen) { UCHAR tmpRate = pAdapter->ScanTab.BssEntry[i].SupRate[pAdapter->ScanTab.BssEntry[i].SupRateLen-1]; memset(&iwe, 0, sizeof(iwe)); iwe.cmd = SIOCGIWRATE; current_val = current_ev + IW_EV_LCP_LEN; if (tmpRate == 0x82) iwe.u.bitrate.value = 1 * 1000000; else if (tmpRate == 0x84) iwe.u.bitrate.value = 2 * 1000000; else if (tmpRate == 0x8B) iwe.u.bitrate.value = 5.5 * 1000000; else if (tmpRate == 0x96) iwe.u.bitrate.value = 11 * 1000000; else iwe.u.bitrate.value = (tmpRate/2) * 1000000; iwe.u.bitrate.disabled = 0; current_val = IWE_STREAM_ADD_VALUE(info, current_ev, current_val, end_buf, &iwe, IW_EV_PARAM_LEN); if((current_val-current_ev)>IW_EV_LCP_LEN) current_ev = current_val; else#if WIRELESS_EXT >= 17 return -E2BIG;#else break;#endif } #ifdef IWEVGENIE //WPA IE if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0) { memset(&iwe, 0, sizeof(iwe)); memset(&custom[0], 0, MAX_CUSTOM_LEN); memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].WpaIE.IE[0]), pAdapter->ScanTab.BssEntry[i].WpaIE.IELen); iwe.cmd = IWEVGENIE; iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].WpaIE.IELen; current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom); if (current_ev == previous_ev)#if WIRELESS_EXT >= 17 return -E2BIG;#else break;#endif } //WPA2 IE if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0) { memset(&iwe, 0, sizeof(iwe)); memset(&custom[0], 0, MAX_CUSTOM_LEN); memcpy(custom, &(pAdapter->ScanTab.BssEntry[i].RsnIE.IE[0]), pAdapter->ScanTab.BssEntry[i].RsnIE.IELen); iwe.cmd = IWEVGENIE; iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].RsnIE.IELen; current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom); if (current_ev == previous_ev)#if WIRELESS_EXT >= 17 return -E2BIG;#else break;#endif }#else //WPA IE //================================ if (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen > 0) { NdisZeroMemory(&iwe, sizeof(iwe)); memset(&custom[0], 0, MAX_CUSTOM_LEN); iwe.cmd = IWEVCUSTOM; iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen * 2) + 7; NdisMoveMemory(custom, "wpa_ie=", 7); for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].WpaIE.IELen; idx++) sprintf(custom, "%s%02x", custom, pAdapter->ScanTab.BssEntry[i].WpaIE.IE[idx]); previous_ev = current_ev; current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom); if (current_ev == previous_ev)#if WIRELESS_EXT >= 17 return -E2BIG;#else break;#endif } //WPA2 IE if (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen > 0) { NdisZeroMemory(&iwe, sizeof(iwe)); memset(&custom[0], 0, MAX_CUSTOM_LEN); iwe.cmd = IWEVCUSTOM; iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen * 2) + 7; NdisMoveMemory(custom, "rsn_ie=", 7); for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].RsnIE.IELen; idx++) sprintf(custom, "%s%02x", custom, pAdapter->ScanTab.BssEntry[i].RsnIE.IE[idx]); previous_ev = current_ev; current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom); if (current_ev == previous_ev)#if WIRELESS_EXT >= 17 return -E2BIG;#else break;#endif }#endif // IWEVGENIE // } data->length = current_ev - extra; pAdapter->StaCfg.bScanReqIsFromWebUI = FALSE; DBGPRINT(RT_DEBUG_ERROR ,("===>rt_ioctl_giwscan. %d(%d) BSS returned, data->length = %d\n",i , pAdapter->ScanTab.BssNr, data->length)); return 0;}#endifint rt_ioctl_siwessid(struct net_device *dev, struct iw_request_info *info, struct iw_point *data, char *essid){ PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv; //check if the interface is down if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) { DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n")); return -ENETDOWN; } if (data->flags) { PSTRING pSsidString = NULL; // Includes null character. if (data->length > (IW_ESSID_MAX_SIZE + 1)) return -E2BIG; pSsidString = kmalloc(MAX_LEN_OF_SSID+1, MEM_ALLOC_FLAG); if (pSsidString) { NdisZeroMemory(pSsidString, MAX_LEN_OF_SSID+1); NdisMoveMemory(pSsidString, essid, data->length); if (Set_SSID_Proc(pAdapter, pSsidString) == FALSE) return -EINVAL; } else return -ENOMEM; } else { // ANY ssid if (Set_SSID_Proc(pAdapter, "") == FALSE) return -EINVAL; } return 0;}int rt_ioctl_giwessid(struct net_device *dev, struct iw_request_info *info, struct iw_point *data, char *essid){ PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv; if (pAdapter == NULL) { /* if 1st open fail, pAd will be free; So the net_dev->priv will be NULL in 2rd open */ return -ENETDOWN; } data->flags = 1; if (MONITOR_ON(pAdapter)) { data->length = 0; return 0; } if (OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) { DBGPRINT(RT_DEBUG_TRACE ,("MediaState is connected\n")); data->length = pAdapter->CommonCfg.SsidLen; memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen); }#ifdef RTMP_MAC_USB #ifdef WPA_SUPPLICANT_SUPPORT // Add for RT2870 else if (pAdapter->StaCfg.WpaSupplicantUP != WPA_SUPPLICANT_DISABLE) { data->length = pAdapter->CommonCfg.SsidLen; memcpy(essid, pAdapter->CommonCfg.Ssid, pAdapter->CommonCfg.SsidLen); }#endif // WPA_SUPPLICANT_SUPPORT //#endif // RTMP_MAC_USB // else {//the ANY ssid was specified data->length = 0; DBGPRINT(RT_DEBUG_TRACE ,("MediaState is not connected, ess\n")); } return 0;}int rt_ioctl_siwnickn(struct net_device *dev, struct iw_request_info *info, struct iw_point *data, char *nickname){ PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv; //check if the interface is down if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) { DBGPRINT(RT_DEBUG_TRACE ,("INFO::Network is down!\n")); return -ENETDOWN; } if (data->length > IW_ESSID_MAX_SIZE) return -EINVAL; memset(pAdapter->nickname, 0, IW_ESSID_MAX_SIZE + 1); memcpy(pAdapter->nickname, nickname, data->length); return 0;}int rt_ioctl_giwnickn(struct net_device *dev, struct iw_request_info *info, struct iw_point *data, char *nickname){ PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv; if (pAdapter == NULL) { /* if 1st open fail, pAd will be free; So the net_dev->priv will be NULL in 2rd open */ return -ENETDOWN; } if (data->length > strlen((PSTRING) pAdapter->nickname) + 1) data->length = strlen((PSTRING) pAdapter->nickname) + 1; if (data->length > 0) { memcpy(nickname, pAdapter->nickname, data->length-1); nickname[data->length-1] = '\0'; } return 0;}int rt_ioctl_siwrts(struct net_device *dev, struct iw_request_info *info, struct iw_param *rts, char *extra){ PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv; u16 val; //check if the interface is down if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) { DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n")); return -ENETDOWN; } if (rts->disabled) val = MAX_RTS_THRESHOLD; else if (rts->value < 0 || rts->value > MAX_RTS_THRESHOLD) return -EINVAL; else if (rts->value == 0) val = MAX_RTS_THRESHOLD; else val = rts->value; if (val != pAdapter->CommonCfg.RtsThreshold) pAdapter->CommonCfg.RtsThreshold = val; return 0;}int rt_ioctl_giwrts(struct net_device *dev, struct iw_request_info *info, struct iw_param *rts, char *extra){ PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv; if (pAdapter == NULL) { /* if 1st open fail, pAd will be free; So the net_dev->priv will be NULL in 2rd open */ return -ENETDOWN; } //check if the interface is down if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) { DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n")); return -ENETDOWN; } rts->value = pAdapter->CommonCfg.RtsThreshold; rts->disabled = (rts->value == MAX_RTS_THRESHOLD); rts->fixed = 1; return 0;}int rt_ioctl_siwfrag(struct net_device *dev, struct iw_request_info *info, struct iw_param *frag, char *extra){ PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv; u16 val; //check if the interface is down if(!RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_INTERRUPT_IN_USE)) { DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n")); return -ENETDOWN; } if (frag->disabled) val = MAX_FRAG_THRESHOLD; else if (frag->value >= MIN_FRAG_THRESHOLD || frag->value <= MAX_FRAG_THRESHOLD) val = __cpu_to_le16(frag->value & ~0x1); /* even numbers only */ else if (frag->value == 0) val = MAX_FRAG_THRESHOLD; else return -EINVAL; pAdapter->CommonCfg.FragmentThreshold = val; return 0;}int rt_ioctl_giwfrag(struct net_device *dev, struct iw_request_info *info, struct iw_param *frag, char *extra){ PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv; if (pAdapter == NULL) { /* if 1st open fail, pAd will be free; So the net_dev->priv will be NULL in 2rd open */ return -ENETDOWN; } //check if the interface is down
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -