softmac: more fixes
Subsystems (2)
PATCH 3/3 softmac: clean up event handling code
In reply to Johannes BergThis patch cleans up the event handling code in ieee80211softmac_event.c and makes the module slightly smaller by removing some strings that are not used any more and consolidating some code.
net/ieee80211/softmac/ieee80211softmac_event.c +10 -15
@@ -38,7 +38,8 @@* The event context is private and can only be used from * within this module. Its meaning varies with the event * type: -* SCAN_FINISHED: no special meaning +* SCAN_FINISHED, +* DISASSOCIATED: NULL * ASSOCIATED, * ASSOCIATE_FAILED, * ASSOCIATE_TIMEOUT,
@@ -59,15 +60,15 @@*/ static char *event_descriptions[IEEE80211SOFTMAC_EVENT_LAST +1 ] = { -"scan finished" , -"associated" , +NULL ,/* scan finished */ +NULL ,/* associated */ "associating failed" ,"associating timed out" ,"authenticated" ,"authenticating failed" ,"authenticating timed out" ,"associating failed because no suitable network was found" , -"disassociated" , +NULL ,/* disassociated */ };
@@ -136,30 +137,24 @@ ieee80211softmac_call_events_locked(struint we_event;char *msg =NULL ; +memset (&wrqu,'\0' ,sizeof (union iwreq_data )); +switch (event) {case IEEE80211SOFTMAC_EVENT_ASSOCIATED : network = (struct ieee80211softmac_network *)event_ctx; - wrqu.data.length =0 ; - wrqu.data.flags =0 ;memcpy (wrqu.ap_addr.sa_data, &network->bssid[0 ],ETH_ALEN ); - wrqu.ap_addr.sa_family =ARPHRD_ETHER ; - we_event =SIOCGIWAP ; -break ; +/* fall through */ case IEEE80211SOFTMAC_EVENT_DISASSOCIATED : - wrqu.data.length =0 ; - wrqu.data.flags =0 ; -memset (&wrqu,'\0' ,sizeof (union iwreq_data )); wrqu.ap_addr.sa_family =ARPHRD_ETHER ; we_event =SIOCGIWAP ;break ;case IEEE80211SOFTMAC_EVENT_SCAN_FINISHED : - wrqu.data.length =0 ; - wrqu.data.flags =0 ; -memset (&wrqu,'\0' ,sizeof (union iwreq_data )); we_event =SIOCGIWSCAN ;break ;default : msg = event_descriptions[event]; +if (!msg) + msg ="SOFTMAC EVENT BUG" ; wrqu.data.length =strlen (msg); we_event =IWEVCUSTOM ;break ;
--
cover softmac: more fixes
This patchset fixes more things in softmac, the first patch implements the SIOCSIWMLME wext, the second fixes the SIOCSIWAP wext and the third cleans up the event code.
The second is a fairly important fix for wpa_supplicant and should probably still go to 2.6.17, the others can go in too of course but aren't that important I think.
johannes
PATCH 2/3 softmac: fix SIOCSIWAP
There are some bugs in the current implementation of the SIOCSIWAP wext, for example that when you do it twice and it fails, it may still try another access point for some reason. This patch fixes this by introducing a new flag that tells the association code that the bssid that is in use was fixed by the user and shouldn't be deviated from.
include/net/ieee80211softmac.h +4 -1
@@ -96,10 +96,13 @@ struct ieee80211softmac_assoc_info {* * bssvalid is true if we found a matching network * and saved it's BSSID into the bssid above. +* +* bssfixed is used for SIOCSIWAP. */ u8 static_essid:1, associating:1, - bssvalid:1; + bssvalid:1, + bssfixed:1;/* Scan retries remaining */ int scan_retry;
net/ieee80211/softmac/ieee80211softmac_assoc.c +16 -4
@@ -144,6 +144,12 @@ network_matches_request(struct ieee80211if (!we_support_all_basic_rates (mac, net->rates_ex, net->rates_ex_len))return 0 ; +/* assume that users know what they're doing ... +* (note we don't let them select a net we're incompatible with) */ +if (mac->associnfo.bssfixed) { +return !memcmp (mac->associnfo.bssid, net->bssid,ETH_ALEN ); + } +/* if 'ANY' network requested, take any that doesn't have privacy enabled */ if (mac->associnfo.req_essid.len ==0 && !(net->capability &WLAN_CAPABILITY_PRIVACY ))
@@ -176,7 +182,7 @@ ieee80211softmac_assoc_work(void *d)ieee80211softmac_disassoc (mac,WLAN_REASON_DISASSOC_STA_HAS_LEFT );/* try to find the requested network in our list, if we found one already */ -if (mac->associnfo.bssvalid) +if (mac->associnfo.bssvalid || mac->associnfo.bssfixed) found =ieee80211softmac_get_network_by_bssid (mac, mac->associnfo.bssid);/* Search the ieee80211 networks for this network if we didn't find it by bssid,
@@ -241,19 +247,25 @@ ieee80211softmac_assoc_work(void *d)if (ieee80211softmac_start_scan (mac)) dprintk(KERN_INFO PFX "Associate: failed to initiate scan. Is device up?\n");return ; - } -else { + }else {spin_lock_irqsave (&mac->lock, flags); mac->associnfo.associating =0 ; mac->associated =0 ;spin_unlock_irqrestore (&mac->lock, flags); dprintk(KERN_INFO PFX "Unable to find matching network after scan!\n"); +/* reset the retry counter for the next user request since we +* break out and don't reschedule ourselves after this point. */ + mac->associnfo.scan_retry =IEEE80211SOFTMAC_ASSOC_SCAN_RETRY_LIMIT ;ieee80211softmac_call_events (mac,IEEE80211SOFTMAC_EVENT_ASSOCIATE_NET_NOT_FOUND ,NULL );return ; } } - + +/* reset the retry counter for the next user request since we +* now found a net and will try to associate to it, but not +* schedule this function again. */ + mac->associnfo.scan_retry =IEEE80211SOFTMAC_ASSOC_SCAN_RETRY_LIMIT ; mac->associnfo.bssvalid =1 ;memcpy (mac->associnfo.bssid, found->bssid,ETH_ALEN );/* copy the ESSID for displaying it */
net/ieee80211/softmac/ieee80211softmac_wx.c +17 -10
@@ -27,7 +27,8 @@#include "ieee80211softmac_priv.h" #include <net/iw_handler.h> - +/* for is_broadcast_ether_addr and is_zero_ether_addr */ +#include <linux/etherdevice.h> int ieee80211softmac_wx_trigger_scan(struct net_device *net_dev,
@@ -83,7 +84,6 @@ ieee80211softmac_wx_set_essid(struct net sm->associnfo.static_essid =1 ; } } - sm->associnfo.scan_retry =IEEE80211SOFTMAC_ASSOC_SCAN_RETRY_LIMIT ;/* set our requested ESSID length. * If applicable, we have already copied the data in */
@@ -310,8 +310,6 @@ ieee80211softmac_wx_set_wap(struct net_d char *extra) {struct ieee80211softmac_device *mac =ieee80211_priv (net_dev); -static const unsigned char any[] = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }; -static const unsigned char off[] = {0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 };unsigned long flags;/* sanity check */
@@ -320,10 +318,17 @@ ieee80211softmac_wx_set_wap(struct net_d }spin_lock_irqsave (&mac->lock, flags); -if (!memcmp (any, data->ap_addr.sa_data,ETH_ALEN ) || - !memcmp (off, data->ap_addr.sa_data,ETH_ALEN )) { -schedule_work (&mac->associnfo.work); - goto out; +if (is_broadcast_ether_addr (data->ap_addr.sa_data)) { +/* the bssid we have is not to be fixed any longer, +* and we should reassociate to the best AP. */ + mac->associnfo.bssfixed =0 ; +/* force reassociation */ + mac->associnfo.bssvalid =0 ; +if (mac->associated) +schedule_work (&mac->associnfo.work); + }else if (is_zero_ether_addr (data->ap_addr.sa_data)) { +/* the bssid we have is no longer fixed */ + mac->associnfo.bssfixed =0 ; }else {if (!memcmp (mac->associnfo.bssid, data->ap_addr.sa_data,ETH_ALEN )) {if (mac->associnfo.associating || mac->associated) {
@@ -333,12 +338,14 @@ ieee80211softmac_wx_set_wap(struct net_d }else {/* copy new value in data->ap_addr.sa_data to bssid */ memcpy (mac->associnfo.bssid, data->ap_addr.sa_data,ETH_ALEN ); - } + } +/* tell the other code that this bssid should be used no matter what */ + mac->associnfo.bssfixed =1 ;/* queue associate if new bssid or (old one again and not associated) */ schedule_work (&mac->associnfo.work); } -out: + out:spin_unlock_irqrestore (&mac->lock, flags);return 0 ; }
net/ieee80211/softmac/ieee80211softmac_module.c +2 -0
@@ -45,6 +45,8 @@ struct net_device *alloc_ieee80211softma 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) */
--
PATCH 1/3 softmac: add SIOCSIWMLME
In reply to Johannes BergThis patch adds the SIOCSIWMLME wext to softmac, this functionality appears to be used by wpa_supplicant and is softmac-specific.
net/ieee80211/softmac/ieee80211softmac_priv.h +1 -0
@@ -150,6 +150,7 @@ int ieee80211softmac_handle_disassoc(strint ieee80211softmac_handle_reassoc_req (struct net_device * dev,struct ieee80211_reassoc_request * reassoc);void ieee80211softmac_assoc_timeout (void *d); +void ieee80211softmac_disassoc (struct ieee80211softmac_device *mac,u16 reason);/* some helper functions */ static inline int ieee80211softmac_scan_handlers_check_self (struct ieee80211softmac_device *sm)
net/ieee80211/softmac/ieee80211softmac_wx.c +32 -0
@@ -424,3 +424,35 @@ ieee80211softmac_wx_get_genie(struct net }EXPORT_SYMBOL_GPL (ieee80211softmac_wx_get_genie); +int +ieee80211softmac_wx_set_mlme (struct net_device *dev, +struct iw_request_info *info, +union iwreq_data *wrqu, +char *extra) +{ +struct ieee80211softmac_device *mac =ieee80211_priv (dev); +struct iw_mlme *mlme = (struct iw_mlme *)extra; +u16 reason =cpu_to_le16 (mlme->reason_code); +struct ieee80211softmac_network *net; + +if (memcmp (mac->associnfo.bssid, mlme->addr.sa_data,ETH_ALEN )) { + printk(KERN_DEBUG PFX "wx_set_mlme: requested operation on net we don't use\n"); +return -EINVAL ; + } + +switch (mlme->cmd) { +case IW_MLME_DEAUTH : + net =ieee80211softmac_get_network_by_bssid_locked (mac, mlme->addr.sa_data); +if (!net) { + printk(KERN_DEBUG PFX "wx_set_mlme: we should know the net here...\n"); +return -EINVAL ; + } +return ieee80211softmac_deauth_req (mac, net, reason); +case IW_MLME_DISASSOC : +ieee80211softmac_disassoc (mac, reason); +return 0 ; +default : +return -EOPNOTSUPP ; + } +} +EXPORT_SYMBOL_GPL (ieee80211softmac_wx_set_mlme);
include/net/ieee80211softmac_wx.h +5 -0
@@ -91,4 +91,9 @@ ieee80211softmac_wx_get_genie(struct netstruct iw_request_info *info, union iwreq_data *wrqu, char *extra); +extern int +ieee80211softmac_wx_set_mlme (struct net_device *dev, +struct iw_request_info *info, +union iwreq_data *wrqu, +char *extra);#endif /* _IEEE80211SOFTMAC_WX */
net/ieee80211/softmac/ieee80211softmac_assoc.c +1 -1
@@ -82,7 +82,7 @@ ieee80211softmac_assoc_timeout(void *d) }/* Sends out a disassociation request to the desired AP */ -static void +void ieee80211softmac_disassoc (struct ieee80211softmac_device *mac,u16 reason) {unsigned long flags;
--