Loading include/net/ieee80211softmac.h 0 → 100644 +292 −0 Original line number Diff line number Diff line /* * ieee80211softmac.h - public interface to the softmac * * Copyright (c) 2005 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. */ #ifndef IEEE80211SOFTMAC_H_ #define IEEE80211SOFTMAC_H_ #include <linux/kernel.h> #include <linux/spinlock.h> #include <linux/workqueue.h> #include <linux/list.h> #include <net/ieee80211.h> /* Once the API is considered more or less stable, * this should be incremented on API incompatible changes. */ #define IEEE80211SOFTMAC_API 0 #define IEEE80211SOFTMAC_MAX_RATES_LEN 8 #define IEEE80211SOFTMAC_MAX_EX_RATES_LEN 255 struct ieee80211softmac_ratesinfo { u8 count; u8 rates[IEEE80211SOFTMAC_MAX_RATES_LEN + IEEE80211SOFTMAC_MAX_EX_RATES_LEN]; }; /* internal structures */ struct ieee80211softmac_network; struct ieee80211softmac_scaninfo; struct ieee80211softmac_essid { u8 len; char data[IW_ESSID_MAX_SIZE+1]; }; struct ieee80211softmac_wpa { char *IE; int IElen; int IEbuflen; }; /* * Information about association * * Do we need a lock for this? * We only ever use this structure inlined * into our global struct. I've used its lock, * but maybe we need a local one here? */ struct ieee80211softmac_assoc_info { /* * This is the requested ESSID. It is written * only by the WX handlers. * */ struct ieee80211softmac_essid req_essid; /* * the ESSID of the network we're currently * associated (or trying) to. This is * updated to the network's actual ESSID * even if the requested ESSID was 'ANY' */ struct ieee80211softmac_essid associate_essid; /* BSSID we're trying to associate to */ char bssid[ETH_ALEN]; /* some flags. * static_essid is valid if the essid is constant, * this is for use by the wx handlers only. * * associating is true, if the network has been * auth'ed on and we are in the process of associating. * * bssvalid is true if we found a matching network * and saved it's BSSID into the bssid above. */ u8 static_essid:1, associating:1, bssvalid:1; /* Scan retries remaining */ int scan_retry; struct work_struct work; struct work_struct timeout; }; enum { IEEE80211SOFTMAC_AUTH_OPEN_REQUEST = 1, IEEE80211SOFTMAC_AUTH_OPEN_RESPONSE = 2, }; enum { IEEE80211SOFTMAC_AUTH_SHARED_REQUEST = 1, IEEE80211SOFTMAC_AUTH_SHARED_CHALLENGE = 2, IEEE80211SOFTMAC_AUTH_SHARED_RESPONSE = 3, IEEE80211SOFTMAC_AUTH_SHARED_PASS = 4, }; /* We should make these tunable * AUTH_TIMEOUT seems really long, but that's what it is in BSD */ #define IEEE80211SOFTMAC_AUTH_TIMEOUT (12 * HZ) #define IEEE80211SOFTMAC_AUTH_RETRY_LIMIT 5 #define IEEE80211SOFTMAC_ASSOC_SCAN_RETRY_LIMIT 3 struct ieee80211softmac_txrates { /* The Bit-Rate to be used for multicast frames. */ u8 mcast_rate; /* The Bit-Rate to be used for multicast fallback * (If the device supports fallback and hardware-retry) */ u8 mcast_fallback; /* The Bit-Rate to be used for any other (normal) data packet. */ u8 default_rate; /* The Bit-Rate to be used for default fallback * (If the device supports fallback and hardware-retry) */ u8 default_fallback; }; /* Bits for txrates_change callback. */ #define IEEE80211SOFTMAC_TXRATECHG_DEFAULT (1 << 0) /* default_rate */ #define IEEE80211SOFTMAC_TXRATECHG_DEFAULT_FBACK (1 << 1) /* default_fallback */ #define IEEE80211SOFTMAC_TXRATECHG_MCAST (1 << 2) /* mcast_rate */ #define IEEE80211SOFTMAC_TXRATECHG_MCAST_FBACK (1 << 3) /* mcast_fallback */ struct ieee80211softmac_device { /* 802.11 structure for data stuff */ struct ieee80211_device *ieee; struct net_device *dev; /* only valid if associated, then holds the Association ID */ u16 association_id; /* the following methods are callbacks that the driver * using this framework has to assign */ /* always assign these */ void (*set_bssid_filter)(struct net_device *dev, const u8 *bssid); void (*set_channel)(struct net_device *dev, u8 channel); /* assign if you need it, informational only */ void (*link_change)(struct net_device *dev); /* If the hardware can do scanning, assign _all_ three of these callbacks. * When the scan finishes, call ieee80211softmac_scan_finished(). */ /* when called, start_scan is guaranteed to not be called again * until you call ieee80211softmac_scan_finished. * Return 0 if scanning could start, error otherwise. * SOFTMAC AUTHORS: don't call this, use ieee80211softmac_start_scan */ int (*start_scan)(struct net_device *dev); /* this should block until after ieee80211softmac_scan_finished was called * SOFTMAC AUTHORS: don't call this, use ieee80211softmac_wait_for_scan */ void (*wait_for_scan)(struct net_device *dev); /* stop_scan aborts a scan, but is asynchronous. * if you want to wait for it too, use wait_for_scan * SOFTMAC AUTHORS: don't call this, use ieee80211softmac_stop_scan */ void (*stop_scan)(struct net_device *dev); /* we'll need something about beacons here too, for AP or ad-hoc modes */ /* Transmission rates to be used by the driver. * The SoftMAC figures out the best possible rates. * The driver just needs to read them. */ struct ieee80211softmac_txrates txrates; /* If the driver needs to do stuff on TX rate changes, assign this callback. */ void (*txrates_change)(struct net_device *dev, u32 changes, /* see IEEE80211SOFTMAC_TXRATECHG flags */ const struct ieee80211softmac_txrates *rates_before_change); /* private stuff follows */ /* this lock protects this structure */ spinlock_t lock; /* couple of flags */ u8 scanning:1, /* protects scanning from being done multiple times at once */ associated:1; struct ieee80211softmac_scaninfo *scaninfo; struct ieee80211softmac_assoc_info associnfo; struct list_head auth_queue; struct list_head events; struct ieee80211softmac_ratesinfo ratesinfo; int txrate_badness; /* WPA stuff */ struct ieee80211softmac_wpa wpa; /* we need to keep a list of network structs we copied */ struct list_head network_list; /* This must be the last item so that it points to the data * allocated beyond this structure by alloc_ieee80211 */ u8 priv[0]; }; extern void ieee80211softmac_scan_finished(struct ieee80211softmac_device *sm); static inline void * ieee80211softmac_priv(struct net_device *dev) { return ((struct ieee80211softmac_device *)ieee80211_priv(dev))->priv; } extern struct net_device * alloc_ieee80211softmac(int sizeof_priv); extern void free_ieee80211softmac(struct net_device *dev); /* Call this function if you detect a lost TX fragment. * (If the device indicates failure of ACK RX, for example.) * It is wise to call this function if you are able to detect lost packets, * because it contributes to the TX Rates auto adjustment. */ extern void ieee80211softmac_fragment_lost(struct net_device *dev, u16 wireless_sequence_number); /* Call this function before _start to tell the softmac what rates * the hw supports. The rates parameter is copied, so you can * free it right after calling this function. * Note that the rates need to be sorted. */ extern void ieee80211softmac_set_rates(struct net_device *dev, u8 count, u8 *rates); /* Start the SoftMAC. Call this after you initialized the device * and it is ready to run. */ extern void ieee80211softmac_start(struct net_device *dev); /* Stop the SoftMAC. Call this before you shutdown the device. */ extern void ieee80211softmac_stop(struct net_device *dev); /* * Event system */ /* valid event types */ #define IEEE80211SOFTMAC_EVENT_ANY -1 /*private use only*/ #define IEEE80211SOFTMAC_EVENT_SCAN_FINISHED 0 #define IEEE80211SOFTMAC_EVENT_ASSOCIATED 1 #define IEEE80211SOFTMAC_EVENT_ASSOCIATE_FAILED 2 #define IEEE80211SOFTMAC_EVENT_ASSOCIATE_TIMEOUT 3 #define IEEE80211SOFTMAC_EVENT_AUTHENTICATED 4 #define IEEE80211SOFTMAC_EVENT_AUTH_FAILED 5 #define IEEE80211SOFTMAC_EVENT_AUTH_TIMEOUT 6 #define IEEE80211SOFTMAC_EVENT_ASSOCIATE_NET_NOT_FOUND 7 /* keep this updated! */ #define IEEE80211SOFTMAC_EVENT_LAST 7 /* * If you want to be notified of certain events, you can call * ieee80211softmac_notify[_atomic] with * - event set to one of the constants below * - fun set to a function pointer of the appropriate type * - context set to the context data you want passed * The return value is 0, or an error. */ typedef void (*notify_function_ptr)(struct net_device *dev, void *context); #define ieee80211softmac_notify(dev, event, fun, context) ieee80211softmac_notify_gfp(dev, event, fun, context, GFP_KERNEL); #define ieee80211softmac_notify_atomic(dev, event, fun, context) ieee80211softmac_notify_gfp(dev, event, fun, context, GFP_ATOMIC); extern int ieee80211softmac_notify_gfp(struct net_device *dev, int event, notify_function_ptr fun, void *context, gfp_t gfp_mask); /* To clear pending work (for ifconfig down, etc.) */ extern void ieee80211softmac_clear_pending_work(struct ieee80211softmac_device *sm); #endif /* IEEE80211SOFTMAC_H_ */ include/net/ieee80211softmac_wx.h 0 → 100644 +94 −0 Original line number Diff line number Diff line /* * This file contains the prototypes for the wireless extension * handlers that the softmac API provides. Include this file to * use the wx handlers, you can assign these directly. * * Copyright (c) 2005 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. */ #ifndef _IEEE80211SOFTMAC_WX_H #define _IEEE80211SOFTMAC_WX_H #include <net/ieee80211softmac.h> #include <net/iw_handler.h> extern int ieee80211softmac_wx_trigger_scan(struct net_device *net_dev, struct iw_request_info *info, union iwreq_data *data, char *extra); extern int ieee80211softmac_wx_get_scan_results(struct net_device *net_dev, struct iw_request_info *info, union iwreq_data *data, char *extra); extern int ieee80211softmac_wx_set_essid(struct net_device *net_dev, struct iw_request_info *info, union iwreq_data *data, char *extra); extern int ieee80211softmac_wx_get_essid(struct net_device *net_dev, struct iw_request_info *info, union iwreq_data *data, char *extra); extern int ieee80211softmac_wx_set_rate(struct net_device *net_dev, struct iw_request_info *info, union iwreq_data *data, char *extra); extern int ieee80211softmac_wx_get_rate(struct net_device *net_dev, struct iw_request_info *info, union iwreq_data *data, char *extra); extern int ieee80211softmac_wx_get_wap(struct net_device *net_dev, struct iw_request_info *info, union iwreq_data *data, char *extra); extern int ieee80211softmac_wx_set_wap(struct net_device *net_dev, struct iw_request_info *info, union iwreq_data *data, char *extra); extern int ieee80211softmac_wx_set_genie(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); extern int ieee80211softmac_wx_get_genie(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); #endif /* _IEEE80211SOFTMAC_WX */ net/ieee80211/Kconfig +1 −0 Original line number Diff line number Diff line Loading @@ -66,3 +66,4 @@ config IEEE80211_CRYPT_TKIP This can be compiled as a modules and it will be called "ieee80211_crypt_tkip". source "net/ieee80211/softmac/Kconfig" net/ieee80211/Makefile +1 −0 Original line number Diff line number Diff line Loading @@ -10,3 +10,4 @@ ieee80211-objs := \ ieee80211_wx.o \ ieee80211_geo.o obj-$(CONFIG_IEEE80211_SOFTMAC) += softmac/ net/ieee80211/ieee80211_rx.c +74 −0 Original line number Diff line number Diff line Loading @@ -780,6 +780,80 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, return 0; } /* Filter out unrelated packets, call ieee80211_rx[_mgt] */ int ieee80211_rx_any(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *stats) { struct ieee80211_hdr_4addr *hdr; int is_packet_for_us; u16 fc; if (ieee->iw_mode == IW_MODE_MONITOR) return ieee80211_rx(ieee, skb, stats) ? 0 : -EINVAL; hdr = (struct ieee80211_hdr_4addr *)skb->data; fc = le16_to_cpu(hdr->frame_ctl); if ((fc & IEEE80211_FCTL_VERS) != 0) return -EINVAL; switch (fc & IEEE80211_FCTL_FTYPE) { case IEEE80211_FTYPE_MGMT: ieee80211_rx_mgt(ieee, hdr, stats); return 0; case IEEE80211_FTYPE_DATA: break; case IEEE80211_FTYPE_CTL: return 0; default: return -EINVAL; } is_packet_for_us = 0; switch (ieee->iw_mode) { case IW_MODE_ADHOC: /* our BSS and not from/to DS */ if (memcmp(hdr->addr3, ieee->bssid, ETH_ALEN) == 0) if ((fc & (IEEE80211_FCTL_TODS+IEEE80211_FCTL_FROMDS)) == 0) { /* promisc: get all */ if (ieee->dev->flags & IFF_PROMISC) is_packet_for_us = 1; /* to us */ else if (memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN) == 0) is_packet_for_us = 1; /* mcast */ else if (is_multicast_ether_addr(hdr->addr1)) is_packet_for_us = 1; } break; case IW_MODE_INFRA: /* our BSS (== from our AP) and from DS */ if (memcmp(hdr->addr2, ieee->bssid, ETH_ALEN) == 0) if ((fc & (IEEE80211_FCTL_TODS+IEEE80211_FCTL_FROMDS)) == IEEE80211_FCTL_FROMDS) { /* promisc: get all */ if (ieee->dev->flags & IFF_PROMISC) is_packet_for_us = 1; /* to us */ else if (memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN) == 0) is_packet_for_us = 1; /* mcast */ else if (is_multicast_ether_addr(hdr->addr1)) { /* not our own packet bcasted from AP */ if (memcmp(hdr->addr3, ieee->dev->dev_addr, ETH_ALEN)) is_packet_for_us = 1; } } break; default: /* ? */ break; } if (is_packet_for_us) return (ieee80211_rx(ieee, skb, stats) ? 0 : -EINVAL); return 0; } #define MGMT_FRAME_FIXED_PART_LENGTH 0x24 static u8 qos_oui[QOS_OUI_LEN] = { 0x00, 0x50, 0xF2 }; Loading Loading
include/net/ieee80211softmac.h 0 → 100644 +292 −0 Original line number Diff line number Diff line /* * ieee80211softmac.h - public interface to the softmac * * Copyright (c) 2005 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. */ #ifndef IEEE80211SOFTMAC_H_ #define IEEE80211SOFTMAC_H_ #include <linux/kernel.h> #include <linux/spinlock.h> #include <linux/workqueue.h> #include <linux/list.h> #include <net/ieee80211.h> /* Once the API is considered more or less stable, * this should be incremented on API incompatible changes. */ #define IEEE80211SOFTMAC_API 0 #define IEEE80211SOFTMAC_MAX_RATES_LEN 8 #define IEEE80211SOFTMAC_MAX_EX_RATES_LEN 255 struct ieee80211softmac_ratesinfo { u8 count; u8 rates[IEEE80211SOFTMAC_MAX_RATES_LEN + IEEE80211SOFTMAC_MAX_EX_RATES_LEN]; }; /* internal structures */ struct ieee80211softmac_network; struct ieee80211softmac_scaninfo; struct ieee80211softmac_essid { u8 len; char data[IW_ESSID_MAX_SIZE+1]; }; struct ieee80211softmac_wpa { char *IE; int IElen; int IEbuflen; }; /* * Information about association * * Do we need a lock for this? * We only ever use this structure inlined * into our global struct. I've used its lock, * but maybe we need a local one here? */ struct ieee80211softmac_assoc_info { /* * This is the requested ESSID. It is written * only by the WX handlers. * */ struct ieee80211softmac_essid req_essid; /* * the ESSID of the network we're currently * associated (or trying) to. This is * updated to the network's actual ESSID * even if the requested ESSID was 'ANY' */ struct ieee80211softmac_essid associate_essid; /* BSSID we're trying to associate to */ char bssid[ETH_ALEN]; /* some flags. * static_essid is valid if the essid is constant, * this is for use by the wx handlers only. * * associating is true, if the network has been * auth'ed on and we are in the process of associating. * * bssvalid is true if we found a matching network * and saved it's BSSID into the bssid above. */ u8 static_essid:1, associating:1, bssvalid:1; /* Scan retries remaining */ int scan_retry; struct work_struct work; struct work_struct timeout; }; enum { IEEE80211SOFTMAC_AUTH_OPEN_REQUEST = 1, IEEE80211SOFTMAC_AUTH_OPEN_RESPONSE = 2, }; enum { IEEE80211SOFTMAC_AUTH_SHARED_REQUEST = 1, IEEE80211SOFTMAC_AUTH_SHARED_CHALLENGE = 2, IEEE80211SOFTMAC_AUTH_SHARED_RESPONSE = 3, IEEE80211SOFTMAC_AUTH_SHARED_PASS = 4, }; /* We should make these tunable * AUTH_TIMEOUT seems really long, but that's what it is in BSD */ #define IEEE80211SOFTMAC_AUTH_TIMEOUT (12 * HZ) #define IEEE80211SOFTMAC_AUTH_RETRY_LIMIT 5 #define IEEE80211SOFTMAC_ASSOC_SCAN_RETRY_LIMIT 3 struct ieee80211softmac_txrates { /* The Bit-Rate to be used for multicast frames. */ u8 mcast_rate; /* The Bit-Rate to be used for multicast fallback * (If the device supports fallback and hardware-retry) */ u8 mcast_fallback; /* The Bit-Rate to be used for any other (normal) data packet. */ u8 default_rate; /* The Bit-Rate to be used for default fallback * (If the device supports fallback and hardware-retry) */ u8 default_fallback; }; /* Bits for txrates_change callback. */ #define IEEE80211SOFTMAC_TXRATECHG_DEFAULT (1 << 0) /* default_rate */ #define IEEE80211SOFTMAC_TXRATECHG_DEFAULT_FBACK (1 << 1) /* default_fallback */ #define IEEE80211SOFTMAC_TXRATECHG_MCAST (1 << 2) /* mcast_rate */ #define IEEE80211SOFTMAC_TXRATECHG_MCAST_FBACK (1 << 3) /* mcast_fallback */ struct ieee80211softmac_device { /* 802.11 structure for data stuff */ struct ieee80211_device *ieee; struct net_device *dev; /* only valid if associated, then holds the Association ID */ u16 association_id; /* the following methods are callbacks that the driver * using this framework has to assign */ /* always assign these */ void (*set_bssid_filter)(struct net_device *dev, const u8 *bssid); void (*set_channel)(struct net_device *dev, u8 channel); /* assign if you need it, informational only */ void (*link_change)(struct net_device *dev); /* If the hardware can do scanning, assign _all_ three of these callbacks. * When the scan finishes, call ieee80211softmac_scan_finished(). */ /* when called, start_scan is guaranteed to not be called again * until you call ieee80211softmac_scan_finished. * Return 0 if scanning could start, error otherwise. * SOFTMAC AUTHORS: don't call this, use ieee80211softmac_start_scan */ int (*start_scan)(struct net_device *dev); /* this should block until after ieee80211softmac_scan_finished was called * SOFTMAC AUTHORS: don't call this, use ieee80211softmac_wait_for_scan */ void (*wait_for_scan)(struct net_device *dev); /* stop_scan aborts a scan, but is asynchronous. * if you want to wait for it too, use wait_for_scan * SOFTMAC AUTHORS: don't call this, use ieee80211softmac_stop_scan */ void (*stop_scan)(struct net_device *dev); /* we'll need something about beacons here too, for AP or ad-hoc modes */ /* Transmission rates to be used by the driver. * The SoftMAC figures out the best possible rates. * The driver just needs to read them. */ struct ieee80211softmac_txrates txrates; /* If the driver needs to do stuff on TX rate changes, assign this callback. */ void (*txrates_change)(struct net_device *dev, u32 changes, /* see IEEE80211SOFTMAC_TXRATECHG flags */ const struct ieee80211softmac_txrates *rates_before_change); /* private stuff follows */ /* this lock protects this structure */ spinlock_t lock; /* couple of flags */ u8 scanning:1, /* protects scanning from being done multiple times at once */ associated:1; struct ieee80211softmac_scaninfo *scaninfo; struct ieee80211softmac_assoc_info associnfo; struct list_head auth_queue; struct list_head events; struct ieee80211softmac_ratesinfo ratesinfo; int txrate_badness; /* WPA stuff */ struct ieee80211softmac_wpa wpa; /* we need to keep a list of network structs we copied */ struct list_head network_list; /* This must be the last item so that it points to the data * allocated beyond this structure by alloc_ieee80211 */ u8 priv[0]; }; extern void ieee80211softmac_scan_finished(struct ieee80211softmac_device *sm); static inline void * ieee80211softmac_priv(struct net_device *dev) { return ((struct ieee80211softmac_device *)ieee80211_priv(dev))->priv; } extern struct net_device * alloc_ieee80211softmac(int sizeof_priv); extern void free_ieee80211softmac(struct net_device *dev); /* Call this function if you detect a lost TX fragment. * (If the device indicates failure of ACK RX, for example.) * It is wise to call this function if you are able to detect lost packets, * because it contributes to the TX Rates auto adjustment. */ extern void ieee80211softmac_fragment_lost(struct net_device *dev, u16 wireless_sequence_number); /* Call this function before _start to tell the softmac what rates * the hw supports. The rates parameter is copied, so you can * free it right after calling this function. * Note that the rates need to be sorted. */ extern void ieee80211softmac_set_rates(struct net_device *dev, u8 count, u8 *rates); /* Start the SoftMAC. Call this after you initialized the device * and it is ready to run. */ extern void ieee80211softmac_start(struct net_device *dev); /* Stop the SoftMAC. Call this before you shutdown the device. */ extern void ieee80211softmac_stop(struct net_device *dev); /* * Event system */ /* valid event types */ #define IEEE80211SOFTMAC_EVENT_ANY -1 /*private use only*/ #define IEEE80211SOFTMAC_EVENT_SCAN_FINISHED 0 #define IEEE80211SOFTMAC_EVENT_ASSOCIATED 1 #define IEEE80211SOFTMAC_EVENT_ASSOCIATE_FAILED 2 #define IEEE80211SOFTMAC_EVENT_ASSOCIATE_TIMEOUT 3 #define IEEE80211SOFTMAC_EVENT_AUTHENTICATED 4 #define IEEE80211SOFTMAC_EVENT_AUTH_FAILED 5 #define IEEE80211SOFTMAC_EVENT_AUTH_TIMEOUT 6 #define IEEE80211SOFTMAC_EVENT_ASSOCIATE_NET_NOT_FOUND 7 /* keep this updated! */ #define IEEE80211SOFTMAC_EVENT_LAST 7 /* * If you want to be notified of certain events, you can call * ieee80211softmac_notify[_atomic] with * - event set to one of the constants below * - fun set to a function pointer of the appropriate type * - context set to the context data you want passed * The return value is 0, or an error. */ typedef void (*notify_function_ptr)(struct net_device *dev, void *context); #define ieee80211softmac_notify(dev, event, fun, context) ieee80211softmac_notify_gfp(dev, event, fun, context, GFP_KERNEL); #define ieee80211softmac_notify_atomic(dev, event, fun, context) ieee80211softmac_notify_gfp(dev, event, fun, context, GFP_ATOMIC); extern int ieee80211softmac_notify_gfp(struct net_device *dev, int event, notify_function_ptr fun, void *context, gfp_t gfp_mask); /* To clear pending work (for ifconfig down, etc.) */ extern void ieee80211softmac_clear_pending_work(struct ieee80211softmac_device *sm); #endif /* IEEE80211SOFTMAC_H_ */
include/net/ieee80211softmac_wx.h 0 → 100644 +94 −0 Original line number Diff line number Diff line /* * This file contains the prototypes for the wireless extension * handlers that the softmac API provides. Include this file to * use the wx handlers, you can assign these directly. * * Copyright (c) 2005 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. */ #ifndef _IEEE80211SOFTMAC_WX_H #define _IEEE80211SOFTMAC_WX_H #include <net/ieee80211softmac.h> #include <net/iw_handler.h> extern int ieee80211softmac_wx_trigger_scan(struct net_device *net_dev, struct iw_request_info *info, union iwreq_data *data, char *extra); extern int ieee80211softmac_wx_get_scan_results(struct net_device *net_dev, struct iw_request_info *info, union iwreq_data *data, char *extra); extern int ieee80211softmac_wx_set_essid(struct net_device *net_dev, struct iw_request_info *info, union iwreq_data *data, char *extra); extern int ieee80211softmac_wx_get_essid(struct net_device *net_dev, struct iw_request_info *info, union iwreq_data *data, char *extra); extern int ieee80211softmac_wx_set_rate(struct net_device *net_dev, struct iw_request_info *info, union iwreq_data *data, char *extra); extern int ieee80211softmac_wx_get_rate(struct net_device *net_dev, struct iw_request_info *info, union iwreq_data *data, char *extra); extern int ieee80211softmac_wx_get_wap(struct net_device *net_dev, struct iw_request_info *info, union iwreq_data *data, char *extra); extern int ieee80211softmac_wx_set_wap(struct net_device *net_dev, struct iw_request_info *info, union iwreq_data *data, char *extra); extern int ieee80211softmac_wx_set_genie(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); extern int ieee80211softmac_wx_get_genie(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); #endif /* _IEEE80211SOFTMAC_WX */
net/ieee80211/Kconfig +1 −0 Original line number Diff line number Diff line Loading @@ -66,3 +66,4 @@ config IEEE80211_CRYPT_TKIP This can be compiled as a modules and it will be called "ieee80211_crypt_tkip". source "net/ieee80211/softmac/Kconfig"
net/ieee80211/Makefile +1 −0 Original line number Diff line number Diff line Loading @@ -10,3 +10,4 @@ ieee80211-objs := \ ieee80211_wx.o \ ieee80211_geo.o obj-$(CONFIG_IEEE80211_SOFTMAC) += softmac/
net/ieee80211/ieee80211_rx.c +74 −0 Original line number Diff line number Diff line Loading @@ -780,6 +780,80 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, return 0; } /* Filter out unrelated packets, call ieee80211_rx[_mgt] */ int ieee80211_rx_any(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *stats) { struct ieee80211_hdr_4addr *hdr; int is_packet_for_us; u16 fc; if (ieee->iw_mode == IW_MODE_MONITOR) return ieee80211_rx(ieee, skb, stats) ? 0 : -EINVAL; hdr = (struct ieee80211_hdr_4addr *)skb->data; fc = le16_to_cpu(hdr->frame_ctl); if ((fc & IEEE80211_FCTL_VERS) != 0) return -EINVAL; switch (fc & IEEE80211_FCTL_FTYPE) { case IEEE80211_FTYPE_MGMT: ieee80211_rx_mgt(ieee, hdr, stats); return 0; case IEEE80211_FTYPE_DATA: break; case IEEE80211_FTYPE_CTL: return 0; default: return -EINVAL; } is_packet_for_us = 0; switch (ieee->iw_mode) { case IW_MODE_ADHOC: /* our BSS and not from/to DS */ if (memcmp(hdr->addr3, ieee->bssid, ETH_ALEN) == 0) if ((fc & (IEEE80211_FCTL_TODS+IEEE80211_FCTL_FROMDS)) == 0) { /* promisc: get all */ if (ieee->dev->flags & IFF_PROMISC) is_packet_for_us = 1; /* to us */ else if (memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN) == 0) is_packet_for_us = 1; /* mcast */ else if (is_multicast_ether_addr(hdr->addr1)) is_packet_for_us = 1; } break; case IW_MODE_INFRA: /* our BSS (== from our AP) and from DS */ if (memcmp(hdr->addr2, ieee->bssid, ETH_ALEN) == 0) if ((fc & (IEEE80211_FCTL_TODS+IEEE80211_FCTL_FROMDS)) == IEEE80211_FCTL_FROMDS) { /* promisc: get all */ if (ieee->dev->flags & IFF_PROMISC) is_packet_for_us = 1; /* to us */ else if (memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN) == 0) is_packet_for_us = 1; /* mcast */ else if (is_multicast_ether_addr(hdr->addr1)) { /* not our own packet bcasted from AP */ if (memcmp(hdr->addr3, ieee->dev->dev_addr, ETH_ALEN)) is_packet_for_us = 1; } } break; default: /* ? */ break; } if (is_packet_for_us) return (ieee80211_rx(ieee, skb, stats) ? 0 : -EINVAL); return 0; } #define MGMT_FRAME_FIXED_PART_LENGTH 0x24 static u8 qos_oui[QOS_OUI_LEN] = { 0x00, 0x50, 0xF2 }; Loading