libertas: minimal WEXT handler for MESH
RFC 1/1 libertas: minimal WEXT handler for MESH
Here I moved some WEXT related for the mesh interface from wext.c into the upcoming "mesh.c". Near the very end of this patch you see the new iw_handler definition.
For many handlers, I simply put NULL there, but I guess that I should do this:
a) register mesh_dev with cfg80211 as well
b) use the handlers from compat-wext.c instead
Is this right? And I guess that I connot do b) without a)
Or is it ok to do b) without a). Would then cfg80211 than always calls into the priv->dev (for the station's struct net_device *). I'm puzzled.
I guess that this patch --- as it is --- will leave you with a broken mesh implementation. Or with a partially broken one, e.g. where you can define mesh-SSID, but you cannot reduce the TX power. Not sure if that is what we want ---- or in other words, not sure if the mesh-WEXT handler really only needs 4 or so handler functions.
drivers/net/wireless/libertas/wext.c +2 -222
@@ -104,45 +104,6 @@ }/** -* @brief Find the channel frequency power info with specific channel -* -* @param priv A pointer to struct lbs_private structure -* @param band it can be BAND_A, BAND_G or BAND_B -* @param channel the channel for looking -* @return A pointer to struct chan_freq_power structure or NULL if not find. -*/ -struct chan_freq_power *lbs_find_cfp_by_band_and_channel ( -struct lbs_private *priv, -u8 band, -u16 channel) -{ -struct chan_freq_power *cfp =NULL ; -struct region_channel *rc; -int i, j; - -for (j =0 ; !cfp && (j <ARRAY_SIZE (priv->region_channel)); j++) { - rc = &priv->region_channel[j]; - -if (!rc->valid || !rc->CFP) -continue ; -if (rc->band != band) -continue ; -for (i =0 ; i < rc->nrcfp; i++) { -if (rc->CFP[i].channel == channel) { - cfp = &rc->CFP[i]; -break ; - } - } - } - -if (!cfp && channel) -lbs_deb_wext ("lbs_find_cfp_by_band_and_channel: can't find " -"cfp by band %d / channel %d\n" , band, channel); - -return cfp; -} - -/** * @brief Find the channel frequency power info with specific frequency * * @param priv A pointer to struct lbs_private structure
@@ -213,7 +174,7 @@return 0 ; } -static int lbs_get_freq (struct net_device *dev,struct iw_request_info *info, +int lbs_get_freq (struct net_device *dev,struct iw_request_info *info,struct iw_freq *fwrq,char *extra) {struct lbs_private *priv = dev->ml_priv;
@@ -422,18 +383,6 @@return 0 ; } -static int mesh_wlan_get_mode (struct net_device *dev, -struct iw_request_info *info,u32 * uwrq, -char *extra) -{ -lbs_deb_enter (LBS_DEB_WEXT ); - - *uwrq =IW_MODE_REPEAT ; - -lbs_deb_leave (LBS_DEB_WEXT ); -return 0 ; -} -static int lbs_get_txpow (struct net_device *dev,struct iw_request_info *info,struct iw_param *vwrq,char *extra)
@@ -838,7 +787,7 @@return 0 ; } -static struct iw_statistics *lbs_get_wireless_stats (struct net_device *dev) +struct iw_statistics *lbs_get_wireless_stats (struct net_device *dev) {enum {POOR =30 ,
@@ -1010,58 +959,6 @@return ret; } -static int lbs_mesh_set_freq (struct net_device *dev, -struct iw_request_info *info, -struct iw_freq *fwrq,char *extra) -{ -struct lbs_private *priv = dev->ml_priv; -struct chan_freq_power *cfp; -int ret = -EINVAL ; - -lbs_deb_enter (LBS_DEB_WEXT ); - -/* If setting by frequency, convert to a channel */ -if (fwrq->e ==1 ) { -long f = fwrq->m /100000 ; - - cfp =find_cfp_by_band_and_freq (priv,0 , f); -if (!cfp) { -lbs_deb_wext ("invalid freq %ld\n" , f); - goto out; - } - - fwrq->e =0 ; - fwrq->m = (int ) cfp->channel; - } - -/* Setting by channel number */ -if (fwrq->m >1000 || fwrq->e >0 ) { - goto out; - } - - cfp =lbs_find_cfp_by_band_and_channel (priv,0 , fwrq->m); -if (!cfp) { - goto out; - } - -if (fwrq->m != priv->channel) { -lbs_deb_wext ("mesh channel change forces eth disconnect\n" ); -if (priv->mode ==IW_MODE_INFRA ) -lbs_cmd_80211_deauthenticate (priv, - priv->curbssparams.bssid, -WLAN_REASON_DEAUTH_LEAVING ); -else if (priv->mode ==IW_MODE_ADHOC ) -lbs_adhoc_stop (priv); - } -lbs_mesh_config (priv,CMD_ACT_MESH_CONFIG_START , fwrq->m); -lbs_update_channel (priv); - ret =0 ; - -out: -lbs_deb_leave_args (LBS_DEB_WEXT ,"ret %d" , ret); -return ret; -} -static int lbs_set_rate (struct net_device *dev,struct iw_request_info *info,struct iw_param *vwrq,char *extra) {
@@ -2110,60 +2007,6 @@return ret; } -static int lbs_mesh_get_essid (struct net_device *dev, -struct iw_request_info *info, -struct iw_point *dwrq,char *extra) -{ -struct lbs_private *priv = dev->ml_priv; - -lbs_deb_enter (LBS_DEB_WEXT ); - -memcpy (extra, priv->mesh_ssid, priv->mesh_ssid_len); - - dwrq->length = priv->mesh_ssid_len; - - dwrq->flags =1 ;/* active */ - -lbs_deb_leave (LBS_DEB_WEXT ); -return 0 ; -} - -static int lbs_mesh_set_essid (struct net_device *dev, -struct iw_request_info *info, -struct iw_point *dwrq,char *extra) -{ -struct lbs_private *priv = dev->ml_priv; -int ret =0 ; - -lbs_deb_enter (LBS_DEB_WEXT ); - -if (!priv->radio_on) { - ret = -EINVAL ; - goto out; - } - -/* Check the size of the string */ -if (dwrq->length >IEEE80211_MAX_SSID_LEN ) { - ret = -E2BIG ; - goto out; - } - -if (!dwrq->flags || !dwrq->length) { - ret = -EINVAL ; - goto out; - }else { -/* Specific SSID requested */ -memcpy (priv->mesh_ssid, extra, dwrq->length); - priv->mesh_ssid_len = dwrq->length; - } - -lbs_mesh_config (priv,CMD_ACT_MESH_CONFIG_START , - priv->channel); - out: -lbs_deb_leave_args (LBS_DEB_WEXT ,"ret %d" , ret); -return ret; -} -/** * @brief Connect to the AP or Ad-hoc Network with specific bssid *
@@ -2270,71 +2113,8 @@ (iw_handler) NULL, /* SIOCSIWPMKSA */ }; -static const iw_handler mesh_wlan_handler[] = { - (iw_handler )NULL ,/* SIOCSIWCOMMIT */ - (iw_handler ) lbs_get_name,/* SIOCGIWNAME */ - (iw_handler )NULL ,/* SIOCSIWNWID */ - (iw_handler )NULL ,/* SIOCGIWNWID */ - (iw_handler ) lbs_mesh_set_freq,/* SIOCSIWFREQ */ - (iw_handler ) lbs_get_freq,/* SIOCGIWFREQ */ - (iw_handler )NULL ,/* SIOCSIWMODE */ - (iw_handler ) mesh_wlan_get_mode,/* SIOCGIWMODE */ - (iw_handler )NULL ,/* SIOCSIWSENS */ - (iw_handler )NULL ,/* SIOCGIWSENS */ - (iw_handler )NULL ,/* SIOCSIWRANGE */ - (iw_handler ) lbs_get_range,/* SIOCGIWRANGE */ - (iw_handler )NULL ,/* SIOCSIWPRIV */ - (iw_handler )NULL ,/* SIOCGIWPRIV */ - (iw_handler )NULL ,/* SIOCSIWSTATS */ - (iw_handler )NULL ,/* SIOCGIWSTATS */ - iw_handler_set_spy,/* SIOCSIWSPY */ - iw_handler_get_spy,/* SIOCGIWSPY */ - iw_handler_set_thrspy,/* SIOCSIWTHRSPY */ - iw_handler_get_thrspy,/* SIOCGIWTHRSPY */ - (iw_handler )NULL ,/* SIOCSIWAP */ - (iw_handler )NULL ,/* SIOCGIWAP */ - (iw_handler )NULL ,/* SIOCSIWMLME */ - (iw_handler )NULL ,/* SIOCGIWAPLIST - deprecated */ - (iw_handler ) lbs_set_scan,/* SIOCSIWSCAN */ - (iw_handler ) lbs_get_scan,/* SIOCGIWSCAN */ - (iw_handler ) lbs_mesh_set_essid,/* SIOCSIWESSID */ - (iw_handler ) lbs_mesh_get_essid,/* SIOCGIWESSID */ - (iw_handler )NULL ,/* SIOCSIWNICKN */ - (iw_handler ) mesh_get_nick,/* SIOCGIWNICKN */ - (iw_handler )NULL ,/* -- hole -- */ - (iw_handler )NULL ,/* -- hole -- */ - (iw_handler ) lbs_set_rate,/* SIOCSIWRATE */ - (iw_handler ) lbs_get_rate,/* SIOCGIWRATE */ - (iw_handler ) lbs_set_rts,/* SIOCSIWRTS */ - (iw_handler ) lbs_get_rts,/* SIOCGIWRTS */ - (iw_handler ) lbs_set_frag,/* SIOCSIWFRAG */ - (iw_handler ) lbs_get_frag,/* SIOCGIWFRAG */ - (iw_handler ) lbs_set_txpow,/* SIOCSIWTXPOW */ - (iw_handler ) lbs_get_txpow,/* SIOCGIWTXPOW */ - (iw_handler ) lbs_set_retry,/* SIOCSIWRETRY */ - (iw_handler ) lbs_get_retry,/* SIOCGIWRETRY */ - (iw_handler ) lbs_set_encode,/* SIOCSIWENCODE */ - (iw_handler ) lbs_get_encode,/* SIOCGIWENCODE */ - (iw_handler ) lbs_set_power,/* SIOCSIWPOWER */ - (iw_handler ) lbs_get_power,/* SIOCGIWPOWER */ - (iw_handler )NULL ,/* -- hole -- */ - (iw_handler )NULL ,/* -- hole -- */ - (iw_handler ) lbs_set_genie,/* SIOCSIWGENIE */ - (iw_handler ) lbs_get_genie,/* SIOCGIWGENIE */ - (iw_handler ) lbs_set_auth,/* SIOCSIWAUTH */ - (iw_handler ) lbs_get_auth,/* SIOCGIWAUTH */ - (iw_handler ) lbs_set_encodeext,/* SIOCSIWENCODEEXT */ - (iw_handler ) lbs_get_encodeext,/* SIOCGIWENCODEEXT */ - (iw_handler )NULL ,/* SIOCSIWPMKSA */ -};struct iw_handler_def lbs_handler_def = { .num_standard =ARRAY_SIZE (lbs_handler), .standard = (iw_handler *) lbs_handler, .get_wireless_stats = lbs_get_wireless_stats, }; - -struct iw_handler_def mesh_handler_def = { - .num_standard =ARRAY_SIZE (mesh_wlan_handler), - .standard = (iw_handler *) mesh_wlan_handler, - .get_wireless_stats = lbs_get_wireless_stats, -};
drivers/net/wireless/libertas/wext.h +13 -0
@@ -4,6 +4,14 @@#ifndef _LBS_WEXT_H_#define _LBS_WEXT_H_ + +struct lbs_private ; +struct net_device ; +struct iw_request_info ; +struct iw_freq ; +struct iw_statistics ; + +void lbs_send_disconnect_notification (struct lbs_private *priv);void lbs_send_mic_failureevent (struct lbs_private *priv,u32 event);
@@ -14,4 +22,9 @@extern struct iw_handler_def lbs_handler_def; +int lbs_get_freq (struct net_device *dev,struct iw_request_info *info, +struct iw_freq *fwrq,char *extra); +struct iw_statistics *lbs_get_wireless_stats (struct net_device *dev); + +#endif
drivers/net/wireless/libertas/persistcfg.c +289 -0
301 lines not on this page · raw message
Signature · 1 line
http://www.holgerschurig.de
Johannes Berg
maintainerQuoted 9 lines · Holger Schurig
For many handlers, I simply put NULL there, but I guess that I should do this:
a) register
mesh_devwith cfg80211 as well
b) use the handlers fromcompat-wext.cinsteadIs this right? And I guess that I connot do b) without a)
Or is it ok to do b) without a).
No, it's not, it'll most certainly segfault.
johannes