📄 atmel.c
字号:
} else { priv->auto_tx_rate = 0; /* Which type of value ? */ if((vwrq->value < 4) && (vwrq->value >= 0)) { /* Setting by rate index */ priv->tx_rate = vwrq->value; } else { /* Setting by frequency value */ switch (vwrq->value) { case (int)1e6: priv->tx_rate = 0; break; case (int)2e6: priv->tx_rate = 1; break; case (int)5.5e6: priv->tx_rate = 2; break; case (int)11e6: priv->tx_rate = 3; break; default: return -EINVAL; } } } return -EINPROGRESS;}static int atmel_set_mode(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra){ struct atmel_private *priv = dev->priv; if (*uwrq != IW_MODE_ADHOC && *uwrq != IW_MODE_INFRA) return -EINVAL; priv->operating_mode = *uwrq; return -EINPROGRESS; }static int atmel_get_mode(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra){ struct atmel_private *priv = dev->priv; *uwrq = priv->operating_mode; return 0;}static int atmel_get_rate(struct net_device *dev, struct iw_request_info *info, struct iw_param *vwrq, char *extra){ struct atmel_private *priv = dev->priv; if (priv->auto_tx_rate) { vwrq->fixed = 0; vwrq->value = 11e6; } else { vwrq->fixed = 1; switch(priv->tx_rate) { case 0: vwrq->value = 1e6; break; case 1: vwrq->value = 2e6; break; case 2: vwrq->value = 5.5e6; break; case 3: vwrq->value = 11e6; break; } } return 0;}static int atmel_set_power(struct net_device *dev, struct iw_request_info *info, struct iw_param *vwrq, char *extra){ struct atmel_private *priv = dev->priv; priv->power_mode = vwrq->disabled ? 0 : 1; return -EINPROGRESS;}static int atmel_get_power(struct net_device *dev, struct iw_request_info *info, struct iw_param *vwrq, char *extra){ struct atmel_private *priv = dev->priv; vwrq->disabled = priv->power_mode ? 0 : 1; vwrq->flags = IW_POWER_ON; return 0;}static int atmel_set_retry(struct net_device *dev, struct iw_request_info *info, struct iw_param *vwrq, char *extra){ struct atmel_private *priv = dev->priv; if(!vwrq->disabled && (vwrq->flags & IW_RETRY_LIMIT)) { if(vwrq->flags & IW_RETRY_MAX) priv->long_retry = vwrq->value; else if (vwrq->flags & IW_RETRY_MIN) priv->short_retry = vwrq->value; else { /* No modifier : set both */ priv->long_retry = vwrq->value; priv->short_retry = vwrq->value; } return -EINPROGRESS; } return -EINVAL;}static int atmel_get_retry(struct net_device *dev, struct iw_request_info *info, struct iw_param *vwrq, char *extra){ struct atmel_private *priv = dev->priv; vwrq->disabled = 0; /* Can't be disabled */ /* Note : by default, display the min retry number */ if((vwrq->flags & IW_RETRY_MAX)) { vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX; vwrq->value = priv->long_retry; } else { vwrq->flags = IW_RETRY_LIMIT; vwrq->value = priv->short_retry; if(priv->long_retry != priv->short_retry) vwrq->flags |= IW_RETRY_MIN; } return 0;}static int atmel_set_rts(struct net_device *dev, struct iw_request_info *info, struct iw_param *vwrq, char *extra){ struct atmel_private *priv = dev->priv; int rthr = vwrq->value; if(vwrq->disabled) rthr = 2347; if((rthr < 0) || (rthr > 2347)) { return -EINVAL; } priv->rts_threshold = rthr; return -EINPROGRESS; /* Call commit handler */}static int atmel_get_rts(struct net_device *dev, struct iw_request_info *info, struct iw_param *vwrq, char *extra){ struct atmel_private *priv = dev->priv; vwrq->value = priv->rts_threshold; vwrq->disabled = (vwrq->value >= 2347); vwrq->fixed = 1; return 0;}static int atmel_set_frag(struct net_device *dev, struct iw_request_info *info, struct iw_param *vwrq, char *extra){ struct atmel_private *priv = dev->priv; int fthr = vwrq->value; if(vwrq->disabled) fthr = 2346; if((fthr < 256) || (fthr > 2346)) { return -EINVAL; } fthr &= ~0x1; /* Get an even value - is it really needed ??? */ priv->frag_threshold = fthr; return -EINPROGRESS; /* Call commit handler */}static int atmel_get_frag(struct net_device *dev, struct iw_request_info *info, struct iw_param *vwrq, char *extra){ struct atmel_private *priv = dev->priv; vwrq->value = priv->frag_threshold; vwrq->disabled = (vwrq->value >= 2346); vwrq->fixed = 1; return 0;}static const long frequency_list[] = { 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484 };static int atmel_set_freq(struct net_device *dev, struct iw_request_info *info, struct iw_freq *fwrq, char *extra){ struct atmel_private *priv = dev->priv; int rc = -EINPROGRESS; /* Call commit handler */ /* If setting by frequency, convert to a channel */ if((fwrq->e == 1) && (fwrq->m >= (int) 2.412e8) && (fwrq->m <= (int) 2.487e8)) { int f = fwrq->m / 100000; int c = 0; while((c < 14) && (f != frequency_list[c])) c++; /* Hack to fall through... */ fwrq->e = 0; fwrq->m = c + 1; } /* Setting by channel number */ if((fwrq->m > 1000) || (fwrq->e > 0)) rc = -EOPNOTSUPP; else { int channel = fwrq->m; if (atmel_validate_channel(priv, channel) == 0) { priv->channel = channel; } else { rc = -EINVAL; } } return rc;}static int atmel_get_freq(struct net_device *dev, struct iw_request_info *info, struct iw_freq *fwrq, char *extra){ struct atmel_private *priv = dev->priv; fwrq->m = priv->channel; fwrq->e = 0; return 0;}static int atmel_set_scan(struct net_device *dev, struct iw_request_info *info, struct iw_param *vwrq, char *extra){ struct atmel_private *priv = dev->priv; /* Note : you may have realised that, as this is a SET operation, * this is privileged and therefore a normal user can't * perform scanning. * This is not an error, while the device perform scanning, * traffic doesn't flow, so it's a perfect DoS... * Jean II */ if (priv->station_state == STATION_STATE_DOWN || priv->station_state == STATION_STATE_NO_CARD) return -EAGAIN; /* Timeout old surveys. */ if ((jiffies - priv->last_survey) > (20 * HZ)) priv->site_survey_state = SITE_SURVEY_IDLE; priv->last_survey = jiffies; /* Initiate a scan command */ if (priv->site_survey_state == SITE_SURVEY_IN_PROGRESS) return -EBUSY; priv->site_survey_state = SITE_SURVEY_IN_PROGRESS; atmel_clear_gcr(dev, GCR_ENINT); /* disable interrupts */ del_timer_sync(&priv->management_timer); atmel_scan(priv, 0); atmel_set_gcr(dev, GCR_ENINT); /* enable interrupts */ return 0;}static int atmel_get_scan(struct net_device *dev, struct iw_request_info *info, struct iw_point *dwrq, char *extra){ struct atmel_private *priv = dev->priv; int i; char *current_ev = extra; struct iw_event iwe; if (priv->site_survey_state != SITE_SURVEY_COMPLETED) return -EAGAIN; for(i=0; i<priv->BSS_list_entries; i++) { iwe.cmd = SIOCGIWAP; iwe.u.ap_addr.sa_family = ARPHRD_ETHER; memcpy(iwe.u.ap_addr.sa_data, priv->BSSinfo[i].BSSID, 6); current_ev = iwe_stream_add_event(current_ev, extra + IW_SCAN_MAX_DATA, &iwe, IW_EV_ADDR_LEN); iwe.u.data.length = priv->BSSinfo[i].SSIDsize; if (iwe.u.data.length > 32) iwe.u.data.length = 32; iwe.cmd = SIOCGIWESSID; iwe.u.data.flags = 1; current_ev = iwe_stream_add_point(current_ev, extra + IW_SCAN_MAX_DATA, &iwe, priv->BSSinfo[i].SSID); iwe.cmd = SIOCGIWMODE; iwe.u.mode = priv->BSSinfo[i].BSStype; current_ev = iwe_stream_add_event(current_ev, extra + IW_SCAN_MAX_DATA, &iwe, IW_EV_UINT_LEN); iwe.cmd = SIOCGIWFREQ; iwe.u.freq.m = priv->BSSinfo[i].channel; iwe.u.freq.e = 0; current_ev = iwe_stream_add_event(current_ev, extra + IW_SCAN_MAX_DATA, &iwe, IW_EV_FREQ_LEN); iwe.cmd = SIOCGIWENCODE; if (priv->BSSinfo[i].UsingWEP) iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; else iwe.u.data.flags = IW_ENCODE_DISABLED; iwe.u.data.length = 0; current_ev = iwe_stream_add_point(current_ev, extra + IW_SCAN_MAX_DATA, &iwe, NULL); } /* Length of data */ dwrq->length = (current_ev - extra); dwrq->flags = 0; /* todo */ return 0;}static int atmel_get_range(struct net_device *dev, struct iw_request_info *info, struct iw_point *dwrq, char *extra){ struct atmel_private *priv = dev->priv; struct iw_range *range = (struct iw_range *) extra; int k,i,j; dwrq->length = sizeof(struct iw_range); memset(range, 0, sizeof(range)); range->min_nwid = 0x0000; range->max_nwid = 0x0000; range->num_channels = 0; for (j = 0; j < sizeof(channel_table)/sizeof(channel_table[0]); j++) if (priv->reg_domain == channel_table[j].reg_domain) { range->num_channels = channel_table[j].max - channel_table[j].min + 1; break; } if (range->num_channels != 0) { for(k = 0, i = channel_table[j].min; i <= channel_table[j].max; i++) { range->freq[k].i = i; /* List index */ range->freq[k].m = frequency_list[i-1] * 100000; range->freq[k++].e = 1; /* Values in table in MHz -> * 10^5 * 10 */ } range->num_frequency = k; } range->max_qual.qual = 100; range->max_qual.level = 100; range->max_qual.noise = 0; range->sensitivity = 0; range->bitrate[0] = 1e6; range->bitrate[1] = 2e6; range->bitrate[2] = 5.5e6; range->bitrate[3] = 11e6; range->num_bitrates = 4; range->min_rts = 0; range->max_rts = 2347; range->min_frag = 256; range->max_frag = 2346; range->encoding_size[0] = 5; range->encoding_size[1] = 13; range->num_encoding_sizes = 2; range->max_encoding_tokens = 4; range->pmp_flags = IW_POWER_ON; range->pmt_flags = IW_POWER_ON; range->pm_capa = 0; range->we_version_source = WIRELESS_EXT; range->we_version_compiled = WIRELESS_EXT; range->retry_capa = IW_RETRY_LIMIT ; range->retry_flags = IW_RETRY_LIMIT; range->r_time_flags = 0; range->min_retry = 1; range->max_retry = 65535; range->avg_qual.qual = 50; range->avg_qual.level = 50; range->avg_qual.noise = 0; return 0;}static int atmel_set_wap(struct net_device *dev, struct iw_request_info *info, struct sockaddr *awrq, char *extra){ struct atmel_private *priv = dev->priv; int i; static const u8 bcast[] = { 255, 255, 255, 255, 255, 255 }; if (awrq->sa_family != ARPHRD_ETHER) return -EINVAL; if (memcmp(bcast, awrq->sa_data, 6) == 0) { atmel_clear_g
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -