⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ieee80211_wireless.c.svn-base

📁 最新之atheros芯片driver source code, 基于linux操作系统,內含atheros芯片HAL全部代码
💻 SVN-BASE
📖 第 1 页 / 共 5 页
字号:
			 */			if (ic->ic_txpowlimit/2 >= rrq->value) {				vap->iv_bss->ni_txpower = 2 * rrq->value;				ic->ic_newtxpowlimit = 2 * rrq->value;				ic->ic_flags |= IEEE80211_F_TXPOW_FIXED;			}			else				return -EINVAL;		}	} else {		if (!fixed)		/* no change */			return 0;		ic->ic_newtxpowlimit = IEEE80211_TXPOWER_MAX;		ic->ic_flags &= ~IEEE80211_F_TXPOW_FIXED;	}done:	return IS_UP(ic->ic_dev) ? ic->ic_reset(ic->ic_dev) : 0;}static intieee80211_get_txcont(struct net_device *dev, 		struct iw_request_info *info, void *w, char *extra){	int *params = (int *)extra;	struct ieee80211vap *vap = netdev_priv(dev);	struct ieee80211com *ic = vap->iv_ic;	params[0] = ic->ic_get_txcont(ic);	return 0;}static intieee80211_get_dfs_cac_time(struct net_device *dev, 		struct iw_request_info *info, void *w, char *extra){	int *params = (int *)extra;	struct ieee80211vap *vap = netdev_priv(dev);	struct ieee80211com *ic = vap->iv_ic;	params[0] = ic->ic_get_dfs_cac_time(ic);	return 0;}static intieee80211_get_dfs_excl_period(struct net_device *dev, 		struct iw_request_info *info, void *w, char *extra){	int *params = (int *)extra;	struct ieee80211vap *vap = netdev_priv(dev);	struct ieee80211com *ic = vap->iv_ic;	params[0] = ic->ic_get_dfs_excl_period(ic);	return 0;}static intieee80211_set_dfs_cac_time(struct net_device *dev, 		struct iw_request_info *info, void *w, char *extra){	int *params = (int *)extra;	struct ieee80211vap *vap = netdev_priv(dev);	struct ieee80211com *ic = vap->iv_ic;	ic->ic_set_dfs_cac_time(ic, params[1]);	return 0;}static intieee80211_set_dfs_excl_period  (struct net_device *dev, 		struct iw_request_info *info, void *w, char *extra){	int *params = (int *)extra;	struct ieee80211vap *vap = netdev_priv(dev);	struct ieee80211com *ic = vap->iv_ic;	ic->ic_set_dfs_excl_period(ic, params[1]);	return 0;}static intieee80211_get_dfs_testmode(struct net_device *dev, 		struct iw_request_info *info, void *w, char *extra){	int *params = (int *)extra;	struct ieee80211vap *vap = netdev_priv(dev);	struct ieee80211com *ic = vap->iv_ic;	params[0] = ic->ic_get_dfs_testmode(ic);	return 0;}static intieee80211_get_txcont_rate(struct net_device *dev, 		struct iw_request_info *info, void *w, char *extra){	int *params = (int *)extra;	struct ieee80211vap *vap = netdev_priv(dev);	struct ieee80211com *ic = vap->iv_ic;	params[0] = ic->ic_get_txcont_rate(ic);	return 0;}static intieee80211_set_txcont(struct net_device *dev, struct iw_request_info *info, 		void *w, char *extra){	int *params = (int *)extra;	struct ieee80211vap *vap = netdev_priv(dev);	struct ieee80211com *ic = vap->iv_ic;	ic->ic_set_txcont(ic, params[1]);	return 0;}static intieee80211_set_dfs_testmode(struct net_device *dev, 		struct iw_request_info *info, void *w, char *extra){	int *params = (int *)extra;	struct ieee80211vap *vap = netdev_priv(dev);	struct ieee80211com *ic = vap->iv_ic;	ic->ic_set_dfs_testmode(ic, params[1]);	return 0;}static intieee80211_set_txcont_rate(struct net_device *dev, 		struct iw_request_info *info, void *w, char *extra){	int *params = (int *)extra;	struct ieee80211vap *vap = netdev_priv(dev);	struct ieee80211com *ic = vap->iv_ic;	ic->ic_set_txcont_rate(ic, params[1]);	return 0;}static intieee80211_set_txcont_power(struct net_device *dev, 		struct iw_request_info *info, void *w, char *extra){	int *params = (int *)extra;	struct ieee80211vap *vap = netdev_priv(dev);	struct ieee80211com *ic = vap->iv_ic;	ic->ic_set_txcont_power(ic, params[1]);	return 0;}static intieee80211_get_txcont_power(struct net_device *dev, 		struct iw_request_info *info, void *w, char *extra){	int *params = (int *)extra;	struct ieee80211vap *vap = netdev_priv(dev);	struct ieee80211com *ic = vap->iv_ic;	params[0] = ic->ic_get_txcont_power(ic);	return 0;}static int ieee80211_ioctl_hal_map(struct net_device *dev, struct iw_request_info *info,       void *w, char *extra){       int *params = (int *)extra;       struct ieee80211vap *vap = netdev_priv(dev);       struct ieee80211com *ic = vap->iv_ic;       params[0] = ic->ic_dump_hal_map(ic);       return 0;}static intieee80211_ioctl_radar(struct net_device *dev, struct iw_request_info *info,	void *w, char *extra){	int *params = (int *)extra;	struct ieee80211vap *vap = netdev_priv(dev);	struct ieee80211com *ic = vap->iv_ic;	if (!(ic->ic_flags & IEEE80211_F_DOTH))		return 0;	params[0] = ic->ic_test_radar(ic);	return 0;}static intieee80211_ioctl_giwtxpow(struct net_device *dev, struct iw_request_info *info,	struct iw_param *rrq, char *extra){	struct ieee80211vap *vap = netdev_priv(dev);	struct ieee80211com *ic = vap->iv_ic;	rrq->value = vap->iv_bss->ni_txpower / 2;	rrq->fixed = (ic->ic_flags & IEEE80211_F_TXPOW_FIXED) != 0;	rrq->disabled = (rrq->fixed && rrq->value == 0);	rrq->flags = IW_TXPOW_DBM;	return 0;}#ifdef ATH_REVERSE_ENGINEERINGstatic intieee80211_dump_registers(struct net_device *dev, struct iw_request_info *info, void *w, char *extra){	unsigned int *params = (unsigned int *)extra;	struct ieee80211vap *vap = netdev_priv(dev);	struct ieee80211com *ic = vap->iv_ic;	switch (params[1]) {	case 2:		ic->ic_registers_mark(ic);		break;	case 1:		ic->ic_registers_dump_delta(ic);		break;	case 0:	default:		ic->ic_registers_dump(ic);		break;	}	return 0;}#endif /* #ifdef ATH_REVERSE_ENGINEERING */#ifdef ATH_REVERSE_ENGINEERINGstatic intieee80211_ioctl_writereg(struct net_device *dev, struct iw_request_info *info, void *w, char *extra){	unsigned int *params = (unsigned int *)extra;	struct ieee80211vap *vap = netdev_priv(dev);	struct ieee80211com *ic = vap->iv_ic;	return ic->ic_write_register(ic, params[0], params[1]);}#endif /* #ifdef ATH_REVERSE_ENGINEERING */#ifdef ATH_REVERSE_ENGINEERINGstatic intieee80211_ioctl_readreg(struct net_device *dev, struct iw_request_info *info, void *w, char *extra){	unsigned int *params = (unsigned int *)extra;	struct ieee80211vap *vap = netdev_priv(dev);	struct ieee80211com *ic = vap->iv_ic;	return ic->ic_read_register(ic, params[0], &params[0]);}#endif /* #ifdef ATH_REVERSE_ENGINEERING */struct waplistreq {	/* XXX: not the right place for declaration? */	struct ieee80211vap *vap;	struct sockaddr addr[IW_MAX_AP];	struct iw_quality qual[IW_MAX_AP];	int i;};static intwaplist_cb(void *arg, const struct ieee80211_scan_entry *se){	struct waplistreq *req = arg;	int i = req->i;	if (i >= IW_MAX_AP)		return 0;	req->addr[i].sa_family = ARPHRD_ETHER;	if (req->vap->iv_opmode == IEEE80211_M_HOSTAP)		IEEE80211_ADDR_COPY(req->addr[i].sa_data, se->se_macaddr);	else		IEEE80211_ADDR_COPY(req->addr[i].sa_data, se->se_bssid);	set_quality(&req->qual[i], se->se_rssi, ATH_DEFAULT_NOISE);	req->i++;	return 0;}static intieee80211_ioctl_iwaplist(struct net_device *dev, struct iw_request_info *info,	struct iw_point *data, char *extra){	struct ieee80211vap *vap = netdev_priv(dev);	struct ieee80211com *ic = vap->iv_ic;	struct waplistreq req;		/* XXX off stack */	req.vap = vap;	req.i = 0;	ieee80211_scan_iterate(ic, waplist_cb, &req);	data->length = req.i;	memcpy(extra, &req.addr, req.i * sizeof(req.addr[0]));	data->flags = 1;		/* signal quality present (sort of) */	memcpy(extra + req.i * sizeof(req.addr[0]), &req.qual,		req.i * sizeof(req.qual[0]));	return 0;}#ifdef SIOCGIWSCANstatic intieee80211_ioctl_siwscan(struct net_device *dev,	struct iw_request_info *info,	struct iw_point *data, char *extra){	struct ieee80211vap *vap = netdev_priv(dev);	/*	 * XXX don't permit a scan to be started unless we	 * know the device is ready.  For the moment this means	 * the device is marked up as this is the required to	 * initialize the hardware.  It would be better to permit	 * scanning prior to being up but that'll require some	 * changes to the infrastructure.	 */	if (!IS_UP(vap->iv_dev))		return -ENETDOWN;	/* XXX always manual... */	IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN,		"%s: active scan request\n", __func__);	preempt_scan(dev, 100, 100);#if WIRELESS_EXT > 17	if (data && (data->flags & IW_SCAN_THIS_ESSID)) {		struct iw_scan_req req;		struct ieee80211_scan_ssid ssid;		int copyLength;		IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN,			"%s: SCAN_THIS_ESSID requested\n", __func__);		if (data->length > sizeof req) {			copyLength = sizeof req;		} else {			copyLength = data->length;		}		memset(&req, 0, sizeof req);		if (copy_from_user(&req, data->pointer, copyLength))			return -EFAULT;		memcpy(&ssid.ssid, req.essid, sizeof ssid.ssid);		ssid.len = req.essid_len;		IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN,				  "%s: requesting scan of essid '%s'\n", __func__, ssid.ssid);		(void) ieee80211_start_scan(vap,			IEEE80211_SCAN_ACTIVE |			IEEE80211_SCAN_NOPICK |			IEEE80211_SCAN_ONCE, IEEE80211_SCAN_FOREVER,			1, &ssid);		return 0;	}#endif	(void) ieee80211_start_scan(vap, IEEE80211_SCAN_ACTIVE |		IEEE80211_SCAN_NOPICK |	IEEE80211_SCAN_ONCE,		IEEE80211_SCAN_FOREVER,		/* XXX use ioctl params */		vap->iv_des_nssid, vap->iv_des_ssid);	return 0;}/* * Encode a WPA or RSN information element as a custom * element using the hostap format. */static u_intencode_ie(void *buf, size_t bufsize, const u_int8_t *ie, size_t ielen,	const char *leader, size_t leader_len){	u_int8_t *p;	int i;	if (bufsize < leader_len)		return 0;	p = buf;	memcpy(p, leader, leader_len);	bufsize -= leader_len;	p += leader_len;	for (i = 0; i < ielen && bufsize > 2; i++) {		p += sprintf(p, "%02x", ie[i]);		bufsize -= 2;	}	return (i == ielen ? p - (u_int8_t *)buf : 0);}struct iwscanreq {		/* XXX: right place for this declaration? */	struct ieee80211vap *vap;	struct iw_request_info *info;	char *current_ev;	char *end_buf;	int mode;};#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) && !defined(IW_REQUEST_FLAG_COMPAT)#define	iwe_stream_add_event(a, b, c, d, e)	iwe_stream_add_event(b, c, d, e)#define	iwe_stream_add_point(a, b, c, d, e)	iwe_stream_add_point(b, c, d, e)#define	iwe_stream_add_value(a, b, c, d, e, f)	\	iwe_stream_add_value(b, c, d, e, f)#define	iwe_stream_lcp_len(a)			IW_EV_LCP_LEN#endifstatic intgiwscan_cb(void *arg, const struct ieee80211_scan_entry *se){	struct iwscanreq *req = arg;	struct ieee80211vap *vap = req->vap;	char *current_ev = req->current_ev;	char *end_buf = req->end_buf;	char *last_ev;#define MAX_IE_LENGTH 64 * 2 + 30	char buf[MAX_IE_LENGTH];#ifndef IWEVGENIE	static const char rsn_leader[] = "rsn_ie=";	static const char wpa_leader[] = "wpa_ie=";#endif	struct iw_event iwe;	char *current_val;	int j;	if (current_ev >= end_buf)		return E2BIG;	/* WPA/!WPA sort criteria */	if ((req->mode != 0) ^ (se->se_wpa_ie != NULL))		return 0;	memset(&iwe, 0, sizeof(iwe));	last_ev = current_ev;	iwe.cmd = SIOCGIWAP;	iwe.u.ap_addr.sa_family = ARPHRD_ETHER;	if (vap->iv_opmode == IEEE80211_M_HOSTAP)		IEEE80211_ADDR_COPY(iwe.u.ap_addr.sa_data, se->se_macaddr);	else		IEEE80211_ADDR_COPY(iwe.u.ap_addr.sa_data, se->se_bssid);	current_ev = iwe_stream_add_event(req->info, current_ev, end_buf,					&iwe, IW_EV_ADDR_LEN);	/* We ran out of space in the buffer. */	if (last_ev == current_ev)	  return E2BIG;	memset(&iwe, 0, sizeof(iwe));	last_ev = current_ev;	iwe.cmd = SIOCGIWESSID;	iwe.u.data.flags = 1;	iwe.u.data.length = se->se_ssid[1];	current_ev = iwe_stream_add_point(req->info, current_ev,			end_buf, &iwe, (char *)se->se_ssid + 2);	/* We ran out of space in the buffer. */	if (last_ev == current_ev)	  return E2BIG;	if (se->se_capinfo & (IEEE80211_CAPINFO_ESS|IEEE80211_CAPINFO_IBSS)) {		memset(&iwe, 0, sizeof(iwe));		last_ev = current_ev;		iwe.cmd = SIOCGIWMODE;		iwe.u.mode = se->se_capinfo & IEEE80211_CAPINFO_ESS ?			IW_MODE_MASTER : IW_MODE_ADHOC;		current_ev = iwe_stream_add_event(req->info, current_ev,				end_buf, &iwe, IW_EV_UINT_LEN);		/* We ran out of space in the buffer. */		if (last_ev == current_ev)		  return E2BIG;	}	memset(&iwe, 0, sizeof(iwe));	last_ev = current_ev;	iwe.cmd = SIOCGIWFREQ;	iwe.u.freq.m = se->se_chan->ic_freq * 100000;	iwe.u.freq.e = 1;	current_ev = iwe_stream_add_event(req->info, current_ev,			end_buf, &iwe, IW_EV_FREQ_LEN);	/* We ran out of space in the buffer. */	if (last_ev == current_ev)	  return E2BIG;	memset(&iwe, 0, sizeof(iwe));	last_ev = current_ev;	iwe.cmd = IWEVQUAL;	set_quality(&iwe.u.qual, se->se_rssi, ATH_DEFAULT_NOISE);	current_ev = iwe_stream_add_event(req->info, current_ev,			end_buf, &iwe, IW_EV_QUAL_LEN);	/* We ran out of space in the buffer */	if (last_ev == current_ev)	  return E2BIG;	memset(&iwe, 0, sizeof(iwe));	last_ev = current_ev;	iwe.cmd = SIOCGIWENCODE;	if (se->se_capinfo & IEEE80211_CAPINFO_PRIVACY)		iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;	else		iwe.u.data.flags = IW_ENCODE_DISABLED;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -