📄 rtmp_info.c
字号:
p = current_ev; current_ev = p + IW_EV_LCP_LEN; for (k = 0, j = 0; k < pBssEntry->SupRateLen; ) { if (j < pBssEntry->ExtRateLen && ((pExtRate[j] & 0x7F) < (pSupRate[k] & 0x7F))) rate = pExtRate[j++] & 0x7F; else rate = pSupRate[k++] & 0x7F; iwe.u.bitrate.value = rate * 500000; previous_ev = current_ev; current_ev = iwe_stream_add_value(p, current_ev, end_buf, &iwe, IW_EV_PARAM_LEN); if (current_ev == previous_ev) goto full; } for (; j < pBssEntry->ExtRateLen; j++) { rate = (pExtRate[j] & 0x7F); iwe.u.bitrate.value = rate * 500000; previous_ev = current_ev; current_ev = iwe_stream_add_value(p, current_ev, end_buf, &iwe, IW_EV_PARAM_LEN); if (current_ev == previous_ev) goto full; } //Quality Statistics //================================ memset(&iwe, 0, sizeof(iwe)); iwe.cmd = IWEVQUAL; set_quality(pAdapter, &iwe.u.qual, pBssEntry->Rssi); previous_ev = current_ev; current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_QUAL_LEN); if (current_ev == previous_ev) break; //Generic IE, now just support WPA(0xdd)/WPA2(0x30) IE //================================ if (pBssEntry->VarIELen > 0) { EID_STRUCT *pEid; UCHAR *pEnd; int EIDLen, isWPA, isRSN; pEid = (PEID_STRUCT)(&pBssEntry->VarIEs[0]); pEnd = (UCHAR *)(&pBssEntry->VarIEs[0] + pBssEntry->VarIELen); // get variable fields from payload and advance the pointer while ( (((UCHAR *)pEid) + sizeof(EID_STRUCT)) <= pEnd) { EIDLen = 2 + pEid->Len; if ((((UCHAR *)pEid) + EIDLen) > pEnd) break; isWPA = isRSN = 0; switch(pEid->Eid) { case IE_WPA: isWPA = NdisEqualMemory(pEid->Octet, WPA_OUI, 4); break; case IE_WPA2: isRSN = RTMPEqualMemory(pEid->Octet + 2, RSN_OUI, 3); break; default: break; } if (isWPA | isRSN) { memset(&iwe, 0, sizeof(iwe)); memset(custom, 0, sizeof(custom));#if WIRELESS_EXT > 17 iwe.cmd = IWEVGENIE; iwe.u.data.length = EIDLen; NdisMoveMemory(custom, pEid, EIDLen);#else iwe.cmd = IWEVCUSTOM; iwe.u.data.length = 7 + EIDLen; if (isWPA) NdisMoveMemory(custom, "wpa_ie=", 7); else if (isRSN) NdisMoveMemory(custom, "rsn_ie=", 7); NdisMoveMemory(&custom[7], pEid, EIDLen);#endif previous_ev = current_ev; current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom); if (current_ev == previous_ev) goto full; } pEid += (2 + pEid->Len); } } } else {#endif // NATIVE_WPA_SUPPLICANT_SUPPORT // // support bit rate#if 1 //Bit Rate //================================ memset(&iwe, 0, sizeof(iwe)); iwe.cmd = SIOCGIWRATE; current_val = current_ev + IW_EV_LCP_LEN; //for (j = 0; j < pAdapter->ScanTab.BssEntry[i].RatesLen;j++) for (j = 0; j < 1;j++) { iwe.u.bitrate.value = RateIdToMbps[pAdapter->ScanTab.BssEntry[i].SupRate[i]/2] * 1000000; iwe.u.bitrate.disabled = 0; current_val = iwe_stream_add_value(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 break; #else // support bit rate, extended rate, quality and last beacon timing // max. of displays used IW_SCAN_MAX_DATA are about 22~24 cells //Bit Rate //================================ memset(&iwe, 0, sizeof(iwe)); iwe.cmd = SIOCGIWRATE; current_val = current_ev + IW_EV_LCP_LEN; SupRateLen = pAdapter->ScanTab.BssEntry[i].SupRateLen; ExtRateLen = pAdapter->ScanTab.BssEntry[i].ExtRateLen; max_rate = 0; p = custom; p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), " Rates (Mb/s): "); for (k = 0, j = 0; k < SupRateLen; ) { if (j < ExtRateLen && ((pAdapter->ScanTab.BssEntry[i].ExtRate[j] & 0x7F) < (pAdapter->ScanTab.BssEntry[i].SupRate[k] & 0x7F))) { rate = pAdapter->ScanTab.BssEntry[i].ExtRate[j++] & 0x7F; } else { rate = pAdapter->ScanTab.BssEntry[i].SupRate[k++] & 0x7F; } if (rate > max_rate) max_rate = rate; p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), "%d%s ", rate >> 1, (rate & 1) ? ".5" : ""); } for (; j < ExtRateLen; j++) { rate = pAdapter->ScanTab.BssEntry[i].ExtRate[j] & 0x7F; p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), "%d%s ", rate >> 1, (rate & 1) ? ".5" : ""); if (rate > max_rate) max_rate = rate; } iwe.u.bitrate.value = max_rate * 500000; iwe.u.bitrate.disabled = 0; current_val = iwe_stream_add_value(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 break; //Extended Rate //================================ memset(&iwe, 0, sizeof(iwe)); iwe.cmd = IWEVCUSTOM; iwe.u.data.length = p - custom; if (iwe.u.data.length) { previous_ev = current_ev; current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom); if (current_ev == previous_ev) break; } //Quality Statistics //================================ memset(&iwe, 0, sizeof(iwe)); iwe.cmd = IWEVQUAL; set_quality(pAdapter, &iwe.u.qual, pAdapter->ScanTab.BssEntry[i].Rssi); previous_ev = current_ev; current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_QUAL_LEN); if (current_ev == previous_ev) break; //Age to display seconds since last beacon //================================ memset(&iwe, 0, sizeof(iwe)); iwe.cmd = IWEVCUSTOM; p = custom; p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), " Last beacon: %lums ago", (jiffies - pAdapter->ScanTab.BssEntry[i].LastBeaconRxTime) / (HZ / 100)); iwe.u.data.length = p - custom; if (iwe.u.data.length) { previous_ev = current_ev; current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, custom); if (current_ev == previous_ev) break; }#endif#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT }#endif memset(&iwe, 0, sizeof(iwe)); }#ifdef NATIVE_WPA_SUPPLICANT_SUPPORTfull:// For wireless_extension >= 17, now can send error back to request more buffer!#if WIRELESS_EXT >= 17 if (pAdapter->PortCfg.bNativeWpa == TRUE) // add by johnli { if (current_ev > end_buf || (current_ev == previous_ev)) { DBGPRINT(RT_DEBUG_TRACE,"===>rt_ioctl_giwscan(-E2BIG). Require more buffer size!\n"); return -E2BIG; } }#endif#endif // NATIVE_WPA_SUPPLICANT_SUPPORT // wrqu->data.length = current_ev - extra; wrqu->data.flags = 0; DBGPRINT(RT_DEBUG_TRACE,"===>rt_ioctl_giwscan. %d(%d) BSS returned\n",i , pAdapter->ScanTab.BssNr); 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; NDIS_802_11_SSID Ssid, *pSsid=NULL; //check if the interface is down if ((dev->flags & IFF_UP) == 0) return -ENETDOWN; if (pAdapter->RTUSBCmdThr_pid < 0) return -ENETDOWN; NdisZeroMemory(&Ssid, sizeof(NDIS_802_11_SSID)); if (data->flags) { if (data->length > IW_ESSID_MAX_SIZE) { return -E2BIG; }#if WIRELESS_EXT < 21 NdisMoveMemory(Ssid.Ssid, essid, (data->length - 1)); Ssid.SsidLength = data->length - 1; //minus null character.#else NdisMoveMemory(Ssid.Ssid, essid, data->length); Ssid.SsidLength = data->length;#endif } else { Ssid.SsidLength = 0; // ANY ssid NdisMoveMemory(Ssid.Ssid, "", 0); }#ifdef NATIVE_WPA_SUPPLICANT_SUPPORT if (pAdapter->PortCfg.bNativeWpa == TRUE) // add by johnli { { NDIS_802_11_REMOVE_KEY removeKey; memset(&removeKey, 0, sizeof(removeKey)); removeKey.KeyIndex = 0xffffffff; //printk("Enqueue remove all AsicShareKey Table cmd first!\n"); RTUSBEnqueueCmdFromNdis(pAdapter, OID_802_11_REMOVE_KEY, TRUE, (PVOID)&removeKey, sizeof(removeKey)); }#if WIRELESS_EXT > 17 if (pAdapter->PortCfg.wx_need_sync) { wext2Rtmp_Security_Wrapper(pAdapter); pAdapter->PortCfg.wx_need_sync = 0; }#endif // WIRELESS_EXT > 17 // if(Ssid.SsidLength == 0) { RTUSBEnqueueCmdFromNdis(pAdapter, OID_802_11_DISASSOCIATE, TRUE, NULL, 0); pAdapter->PortCfg.SsidLen = 0; memset(pAdapter->PortCfg.Ssid, 0, MAX_LEN_OF_SSID); return 0; } if ((pAdapter->PortCfg.WepStatus == Ndis802_11Encryption1Enabled) && (pAdapter->PortCfg.IEEE8021X != TRUE)) { union { char buf[sizeof(NDIS_802_11_WEP)+MAX_LEN_OF_KEY- 1]; NDIS_802_11_WEP keyinfo; } WepKey; int KeyIdx; DBGPRINT(RT_DEBUG_TRACE, "EncrypType=WEP, set Key to Asic!\n"); for (KeyIdx = 0; KeyIdx < 4; KeyIdx++) { if (pAdapter->SharedKey[KeyIdx].KeyLen == 0) continue; NdisZeroMemory(&WepKey, sizeof(WepKey)); WepKey.keyinfo.KeyLength = pAdapter->SharedKey[KeyIdx].KeyLen; NdisMoveMemory(WepKey.keyinfo.KeyMaterial, pAdapter->SharedKey[KeyIdx].Key, WepKey.keyinfo.KeyLength); WepKey.keyinfo.KeyIndex = KeyIdx; if (pAdapter->PortCfg.DefaultKeyId == KeyIdx); WepKey.keyinfo.KeyIndex |= 0x80000000; WepKey.keyinfo.Length = sizeof(WepKey.keyinfo)+ WepKey.keyinfo.KeyLength -1; DBGPRINT(RT_DEBUG_TRACE, "%s():Set WEP key to key[0x%x]!\n", __FUNCTION__, KeyIdx); RTUSBEnqueueCmdFromNdis(pAdapter, OID_802_11_ADD_WEP, TRUE, (PVOID)&WepKey, WepKey.keyinfo.Length); } } }#endif // NATIVE_WPA_SUPPLICANT_SUPPORT // pSsid = &Ssid; if ((pAdapter->Mlme.CntlMachine.CurrState != CNTL_IDLE) && (pAdapter->MLMEThr_pid > 0)) { MlmeEnqueue(pAdapter, MLME_CNTL_STATE_MACHINE, RT_CMD_RESET_MLME, 0, NULL); } // tell CNTL state machine to call NdisMSetInformationComplete() after completing // this request, because this request is initiated by NDIS. // To prevent some kernel thread is very low priority ...so essid copy immediately for later wpapsk counting. if (pAdapter->PortCfg.AuthMode >= Ndis802_11AuthModeWPA) { NdisZeroMemory(pAdapter->MlmeAux.Ssid, MAX_LEN_OF_SSID); NdisMoveMemory(pAdapter->MlmeAux.Ssid, Ssid.Ssid, Ssid.SsidLength); pAdapter->MlmeAux.SsidLen = Ssid.SsidLength; } DBGPRINT(RT_DEBUG_TRACE, "===>rt_ioctl_siwessid:: (Ssid.SsidLength = %d, %s)\n",Ssid.SsidLength, Ssid.Ssid); if (pAdapter->MLMEThr_pid > 0) { MlmeEnqueue(pAdapter, MLME_CNTL_STATE_MACHINE, OID_802_11_SSID, sizeof(NDIS_802_11_SSID), (VOID *)pSsid); } RTUSBMlmeUp(pAdapter); return 0;}int rt_ioctl_giwessid(struct net_device *dev, struct iw_request_info *info, struct iw_point *data, char *extra){ PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv; if (pAdapter->RTUSBCmdThr_pid < 0) return -ENETDOWN; if (OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) { DBGPRINT(RT_DEBUG_TRACE,"MediaState is connected\n"); data->length = pAdapter->PortCfg.SsidLen; memcpy(extra, pAdapter->PortCfg.Ssid, pAdapter->PortCfg.SsidLen); data->flags = 1; /* active */ pAdapter->PortCfg.Ssid[pAdapter->PortCfg.SsidLen] = '\0'; DBGPRINT(RT_DEBUG_TRACE,"pAdapter->PortCfg.Ssid=%s , Ssidlen = %d\n",pAdapter->PortCfg.Ssid, pAdapter->PortCfg.SsidLen); } else {//the ANY ssid was specified data->length = 0; data->flags = 0; DBGPRINT(RT_DEBUG_TRACE,"MediaState is not connected, ess\n"); } DBGPRINT(RT_DEBUG_TRACE, "===>rt_ioctl_giwessid:: (Len=%d, ssid=%s...)\n", pAdapter->PortCfg.SsidLen, pAdapter->PortCfg.Ssid); 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 ((dev->flags & IFF_UP) == 0) return -ENETDOWN; if (pAdapter->RTUSBCmdThr_pid < 0) return -ENETDOWN; if (data->length > IW_ESSID_MAX_SIZE) return -EINVAL; memset(pAdapter->nickn, 0, IW_ESSID_MAX_SIZE); memcpy(pAdapter->nickn, 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->RTUSBCmdThr_pid < 0) return -ENETDOWN; if (data->length > strlen(pAdapter->nickn) + 1) data->length = strlen(pAdapter->nickn) + 1; if (data->length > 0) { memcpy(nickname, pAdapter->nickn, data->length-1); nickname[data->length-1] = '\0';
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -