📄 rtmp_info.c
字号:
range->max_frag = 2346;
return 0;
}
int rt_ioctl_giwap(struct net_device *dev,
struct iw_request_info *info,
struct sockaddr *ap_addr, char *extra)
{
PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
//check if the interface is down
if (pAdapter->RTUSBCmdThr_pid < 0)
return -ENETDOWN;
if (INFRA_ON(pAdapter) || ADHOC_ON(pAdapter))
{
ap_addr->sa_family = ARPHRD_ETHER;
memcpy(ap_addr->sa_data, &pAdapter->PortCfg.Bssid, ETH_ALEN);
}
else
{
DBGPRINT(RT_DEBUG_TRACE, "IOCTL::SIOCGIWAP(=EMPTY)\n");
return -ENOTCONN;
}
return 0;
}
/*
* Units are in db above the noise floor. That means the
* rssi values reported in the tx/rx descriptors in the
* driver are the SNR expressed in db.
*
* If you assume that the noise floor is -95, which is an
* excellent assumption 99.5 % of the time, then you can
* derive the absolute signal level (i.e. -95 + rssi).
* There are some other slight factors to take into account
* depending on whether the rssi measurement is from 11b,
* 11g, or 11a. These differences are at most 2db and
* can be documented.
*
* NB: various calculations are based on the orinoco/wavelan
* drivers for compatibility
*/
static void set_quality(PRTMP_ADAPTER pAdapter,
struct iw_quality *iq,
u_int rssi)
{
u32 ChannelQuality, NorRssi;
// Normalize Rssi
if (rssi > 0x50)
NorRssi = 100;
else if (rssi < 0x20)
NorRssi = 0;
else
NorRssi = (rssi - 0x20) * 2;
// ChannelQuality = W1*RSSI + W2*TxPRR + W3*RxPER (RSSI 0..100), (TxPER 100..0), (RxPER 100..0)
ChannelQuality = (RSSI_WEIGHTING * NorRssi +
TX_WEIGHTING * (100 - 0) +
RX_WEIGHTING* (100 - 0)) / 100;
if (ChannelQuality >= 100)
ChannelQuality = 100;
iq->qual = ChannelQuality;
#ifdef RTMP_EMBEDDED
iq->level = rt_abs(rssi); // signal level (dBm)
#else
iq->level = abs(rssi); // signal level (dBm)
#endif
iq->level += 256 - pAdapter->BbpRssiToDbmDelta;
iq->noise = (pAdapter->BbpWriteLatch[17] > pAdapter->BbpTuning.R17UpperBoundG) ? pAdapter->BbpTuning.R17UpperBoundG : ((ULONG) pAdapter->BbpWriteLatch[17]); // noise level (dBm)
iq->noise += 256 - 143;
iq->updated = pAdapter->iw_stats.qual.updated;
}
int rt_ioctl_iwaplist(struct net_device *dev,
struct iw_request_info *info,
struct iw_point *data, char *extra)
{
PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
struct sockaddr addr[IW_MAX_AP];
struct iw_quality qual[IW_MAX_AP];
int i;
//check if the interface is down
if (pAdapter->RTUSBCmdThr_pid < 0)
return -ENETDOWN;
for (i = 0; i <IW_MAX_AP ; i++)
{
if (i >= pAdapter->ScanTab.BssNr)
break;
addr[i].sa_family = ARPHRD_ETHER;
memcpy(addr[i].sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, MAC_ADDR_LEN);
set_quality(pAdapter, &qual[i], pAdapter->ScanTab.BssEntry[i].Rssi);
}
data->length = i;
memcpy(extra, &addr, i*sizeof(addr[0]));
data->flags = 1; /* signal quality present (sort of) */
memcpy(extra + i*sizeof(addr[0]), &qual, i*sizeof(qual[i]));
return 0;
}
#ifdef SIOCGIWSCAN
int rt_ioctl_siwscan(struct net_device *dev,
struct iw_request_info *info,
struct iw_point *data, char *extra)
{
ULONG Now;
PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
int Status = NDIS_STATUS_SUCCESS;
//BOOLEAN StateMachineTouched = FALSE;
//check if the interface is down
if (pAdapter->RTUSBCmdThr_pid < 0)
return -ENETDOWN;
if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS))
return 0;
do{
Now = jiffies;
if ((OPSTATUS_TEST_FLAG(pAdapter, fOP_STATUS_MEDIA_STATE_CONNECTED)) &&
((pAdapter->PortCfg.AuthMode == Ndis802_11AuthModeWPA) ||
(pAdapter->PortCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||
(pAdapter->PortCfg.AuthMode == Ndis802_11AuthModeWPA2) ||
(pAdapter->PortCfg.AuthMode == Ndis802_11AuthModeWPA2PSK)) &&
(pAdapter->PortCfg.PortSecured == WPA_802_1X_PORT_NOT_SECURED)
)
{
DBGPRINT(RT_DEBUG_TRACE, "!!! Link UP, Port Not Secured! ignore this set::OID_802_11_BSSID_LIST_SCAN\n");
Status = NDIS_STATUS_SUCCESS;
break;
}
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.
pAdapter->MlmeAux.CurrReqIsFromNdis = FALSE;
// Reset Missed scan number
pAdapter->PortCfg.ScanCnt = 0;
pAdapter->PortCfg.LastScanTime = Now;
MlmeEnqueue(pAdapter,
MLME_CNTL_STATE_MACHINE,
OID_802_11_BSSID_LIST_SCAN,
0,
NULL);
RTUSBMlmeUp(pAdapter);
Status = NDIS_STATUS_SUCCESS;
//StateMachineTouched = TRUE;
}while(0);
return 0;
}
#define MAX_CUSTOM_LEN 64
int
rt_ioctl_giwscan(struct net_device *dev,
struct iw_request_info *info,
struct iw_point *data, char *extra)
{
PRTMP_ADAPTER pAdapter = (PRTMP_ADAPTER) dev->priv;
int i=2, j;
char *current_ev = extra, *previous_ev = extra;
char *end_buf = extra + IW_SCAN_MAX_DATA; // some of platforms restricted on IW_SCAN_MAX_DATA
char *current_val;
struct iw_event iwe;
#if 0 // support bit rate, extended rate, quality and last beacon timing
//-------------------------------------------
char custom[MAX_CUSTOM_LEN];
char *p;
char SupRateLen, ExtRateLen;
char rate, max_rate;
int k;
//-------------------------------------------
#endif
//check if the interface is down
if (pAdapter->RTUSBCmdThr_pid < 0)
return -ENETDOWN;
if (RTMP_TEST_FLAG(pAdapter, fRTMP_ADAPTER_BSS_SCAN_IN_PROGRESS)){
/*
* Still scanning, indicate the caller should try again.
*/
return -EAGAIN;
}
for (i = 0; i < pAdapter->ScanTab.BssNr; i++)
{
if (current_ev >= end_buf)
break;
//MAC address
//================================
memset(&iwe, 0, sizeof(iwe));
iwe.cmd = SIOCGIWAP;
iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
memcpy(iwe.u.ap_addr.sa_data, &pAdapter->ScanTab.BssEntry[i].Bssid, ETH_ALEN);
previous_ev = current_ev;
current_ev = iwe_stream_add_event(current_ev,end_buf, &iwe, IW_EV_ADDR_LEN);
if (current_ev == previous_ev)
break;
//ESSID
//================================
memset(&iwe, 0, sizeof(iwe));
iwe.cmd = SIOCGIWESSID;
iwe.u.data.length = pAdapter->ScanTab.BssEntry[i].SsidLen;
iwe.u.data.flags = 1;
previous_ev = current_ev;
current_ev = iwe_stream_add_point(current_ev,end_buf, &iwe, pAdapter->ScanTab.BssEntry[i].Ssid);
if (current_ev == previous_ev)
break;
//Network Type
//================================
memset(&iwe, 0, sizeof(iwe));
iwe.cmd = SIOCGIWMODE;
if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11IBSS)
{
iwe.u.mode = IW_MODE_ADHOC;
}
else if (pAdapter->ScanTab.BssEntry[i].BssType == Ndis802_11Infrastructure)
{
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(current_ev, end_buf, &iwe, IW_EV_UINT_LEN);
if (current_ev == previous_ev)
break;
//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(current_ev,end_buf, &iwe, IW_EV_FREQ_LEN);
if (current_ev == previous_ev)
break;
//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(current_ev, end_buf,&iwe, (char *)pAdapter->SharedKey[(iwe.u.data.flags & IW_ENCODE_INDEX)-1].Key);
if (current_ev == previous_ev)
break;
#if 1 // support bit rate
//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;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -