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

📄 ieee80211softmac_module.c

📁 LINUX 2.6.17.4的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * Contains some basic softmac functions along with module registration code etc. * * Copyright (c) 2005, 2006 Johannes Berg <johannes@sipsolutions.net> *                          Joseph Jezak <josejx@gentoo.org> *                          Larry Finger <Larry.Finger@lwfinger.net> *                          Danny van Dyk <kugelfang@gentoo.org> *                          Michael Buesch <mbuesch@freenet.de> * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA * * The full GNU General Public License is included in this distribution in the * file called COPYING. */#include "ieee80211softmac_priv.h"#include <linux/sort.h>struct net_device *alloc_ieee80211softmac(int sizeof_priv){	struct ieee80211softmac_device *softmac;	struct net_device *dev;		dev = alloc_ieee80211(sizeof(struct ieee80211softmac_device) + sizeof_priv);	softmac = ieee80211_priv(dev);	softmac->dev = dev;	softmac->ieee = netdev_priv(dev);	spin_lock_init(&softmac->lock);		softmac->ieee->handle_auth = ieee80211softmac_auth_resp;	softmac->ieee->handle_deauth = ieee80211softmac_deauth_resp;	softmac->ieee->handle_assoc_response = ieee80211softmac_handle_assoc_response;	softmac->ieee->handle_reassoc_request = ieee80211softmac_handle_reassoc_req;	softmac->ieee->handle_disassoc = ieee80211softmac_handle_disassoc;	softmac->scaninfo = NULL;	softmac->associnfo.scan_retry = IEEE80211SOFTMAC_ASSOC_SCAN_RETRY_LIMIT;	/* TODO: initialise all the other callbacks in the ieee struct	 *	 (once they're written)	 */	INIT_LIST_HEAD(&softmac->auth_queue);	INIT_LIST_HEAD(&softmac->network_list);	INIT_LIST_HEAD(&softmac->events);	INIT_WORK(&softmac->associnfo.work, ieee80211softmac_assoc_work, softmac);	INIT_WORK(&softmac->associnfo.timeout, ieee80211softmac_assoc_timeout, softmac);	softmac->start_scan = ieee80211softmac_start_scan_implementation;	softmac->wait_for_scan = ieee80211softmac_wait_for_scan_implementation;	softmac->stop_scan = ieee80211softmac_stop_scan_implementation;	//TODO: The mcast rate has to be assigned dynamically somewhere (in scanning, association. Not sure...)	//      It has to be set to the highest rate all stations in the current network can handle.	softmac->txrates.mcast_rate = IEEE80211_CCK_RATE_1MB;	softmac->txrates.mcast_fallback = IEEE80211_CCK_RATE_1MB;	/* This is reassigned in ieee80211softmac_start to sane values. */	softmac->txrates.default_rate = IEEE80211_CCK_RATE_1MB;	softmac->txrates.default_fallback = IEEE80211_CCK_RATE_1MB;	/* to start with, we can't send anything ... */	netif_carrier_off(dev);		return dev;}EXPORT_SYMBOL_GPL(alloc_ieee80211softmac);/* Clears the pending work queue items, stops all scans, etc. */void ieee80211softmac_clear_pending_work(struct ieee80211softmac_device *sm){	unsigned long flags;	struct ieee80211softmac_event *eventptr, *eventtmp;	struct ieee80211softmac_auth_queue_item *authptr, *authtmp;	struct ieee80211softmac_network *netptr, *nettmp;		ieee80211softmac_stop_scan(sm);	ieee80211softmac_wait_for_scan(sm);		spin_lock_irqsave(&sm->lock, flags);	sm->running = 0;	/* Free all pending assoc work items */	cancel_delayed_work(&sm->associnfo.work);		/* Free all pending scan work items */	if(sm->scaninfo != NULL)		cancel_delayed_work(&sm->scaninfo->softmac_scan);			/* Free all pending auth work items */	list_for_each_entry(authptr, &sm->auth_queue, list)		cancel_delayed_work(&authptr->work);		/* delete all pending event calls and work items */	list_for_each_entry_safe(eventptr, eventtmp, &sm->events, list)		cancel_delayed_work(&eventptr->work);	spin_unlock_irqrestore(&sm->lock, flags);	flush_scheduled_work();	/* now we should be save and no longer need locking... */	spin_lock_irqsave(&sm->lock, flags);	/* Free all pending auth work items */	list_for_each_entry_safe(authptr, authtmp, &sm->auth_queue, list) {		list_del(&authptr->list);		kfree(authptr);	}		/* delete all pending event calls and work items */	list_for_each_entry_safe(eventptr, eventtmp, &sm->events, list) {		list_del(&eventptr->list);		kfree(eventptr);	}			/* Free all networks */	list_for_each_entry_safe(netptr, nettmp, &sm->network_list, list) {		ieee80211softmac_del_network_locked(sm, netptr);		if(netptr->challenge != NULL)			kfree(netptr->challenge);		kfree(netptr);	}	spin_unlock_irqrestore(&sm->lock, flags);}EXPORT_SYMBOL_GPL(ieee80211softmac_clear_pending_work);void free_ieee80211softmac(struct net_device *dev){	struct ieee80211softmac_device *sm = ieee80211_priv(dev);	ieee80211softmac_clear_pending_work(sm);		kfree(sm->scaninfo);	kfree(sm->wpa.IE);	free_ieee80211(dev);}EXPORT_SYMBOL_GPL(free_ieee80211softmac);static void ieee80211softmac_start_check_rates(struct ieee80211softmac_device *mac){	struct ieee80211softmac_ratesinfo *ri = &mac->ratesinfo;	/* I took out the sorting check, we're seperating by modulation now. */	if (ri->count)		return;	/* otherwise assume we hav'em all! */	if (mac->ieee->modulation & IEEE80211_CCK_MODULATION) {		ri->rates[ri->count++] = IEEE80211_CCK_RATE_1MB;		ri->rates[ri->count++] = IEEE80211_CCK_RATE_2MB;		ri->rates[ri->count++] = IEEE80211_CCK_RATE_5MB;		ri->rates[ri->count++] = IEEE80211_CCK_RATE_11MB;	}	if (mac->ieee->modulation & IEEE80211_OFDM_MODULATION) {		ri->rates[ri->count++] = IEEE80211_OFDM_RATE_6MB;		ri->rates[ri->count++] = IEEE80211_OFDM_RATE_9MB;		ri->rates[ri->count++] = IEEE80211_OFDM_RATE_12MB;		ri->rates[ri->count++] = IEEE80211_OFDM_RATE_18MB;		ri->rates[ri->count++] = IEEE80211_OFDM_RATE_24MB;		ri->rates[ri->count++] = IEEE80211_OFDM_RATE_36MB;		ri->rates[ri->count++] = IEEE80211_OFDM_RATE_48MB;		ri->rates[ri->count++] = IEEE80211_OFDM_RATE_54MB;	}}void ieee80211softmac_start(struct net_device *dev){	struct ieee80211softmac_device *mac = ieee80211_priv(dev);	struct ieee80211_device *ieee = mac->ieee;	u32 change = 0;	struct ieee80211softmac_txrates oldrates;	ieee80211softmac_start_check_rates(mac);	/* TODO: We need some kind of state machine to lower the default rates	 *       if we loose too many packets.	 */	/* Change the default txrate to the highest possible value.	 * The txrate machine will lower it, if it is too high.	 */	if (mac->txrates_change)		oldrates = mac->txrates;	/* FIXME: We don't correctly handle backing down to lower	   rates, so 801.11g devices start off at 11M for now. People	   can manually change it if they really need to, but 11M is	   more reliable. Note similar logic in	   ieee80211softmac_wx_set_rate() */	 	if (ieee->modulation & IEEE80211_CCK_MODULATION) {		mac->txrates.default_rate = IEEE80211_CCK_RATE_11MB;		change |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT;		mac->txrates.default_fallback = IEEE80211_CCK_RATE_5MB;		change |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT_FBACK;	} else if (ieee->modulation & IEEE80211_OFDM_MODULATION) {		mac->txrates.default_rate = IEEE80211_OFDM_RATE_54MB;		change |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT;		mac->txrates.default_fallback = IEEE80211_OFDM_RATE_24MB;		change |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT_FBACK;	} else		assert(0);	if (mac->txrates_change)		mac->txrates_change(dev, change, &oldrates);	mac->running = 1;}EXPORT_SYMBOL_GPL(ieee80211softmac_start);void ieee80211softmac_stop(struct net_device *dev){	struct ieee80211softmac_device *mac = ieee80211_priv(dev);	ieee80211softmac_clear_pending_work(mac);}EXPORT_SYMBOL_GPL(ieee80211softmac_stop);void ieee80211softmac_set_rates(struct net_device *dev, u8 count, u8 *rates){	struct ieee80211softmac_device *mac = ieee80211_priv(dev);	unsigned long flags;		spin_lock_irqsave(&mac->lock, flags);	memcpy(mac->ratesinfo.rates, rates, count);	mac->ratesinfo.count = count;	spin_unlock_irqrestore(&mac->lock, flags);}EXPORT_SYMBOL_GPL(ieee80211softmac_set_rates);static u8 raise_rate(struct ieee80211softmac_device *mac, u8 rate){

⌨️ 快捷键说明

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