2006-01-12 21:12:59 +01:00
|
|
|
/*
|
|
|
|
* Internal softmac API definitions.
|
|
|
|
*
|
2006-01-31 19:31:41 +01:00
|
|
|
* 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>
|
2006-01-12 21:12:59 +01:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2006-01-04 16:32:16 +01:00
|
|
|
#ifndef IEEE80211SOFTMAC_PRIV_H_
|
|
|
|
#define IEEE80211SOFTMAC_PRIV_H_
|
|
|
|
|
|
|
|
#include <net/ieee80211softmac.h>
|
|
|
|
#include <net/ieee80211softmac_wx.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/stringify.h>
|
|
|
|
|
|
|
|
|
|
|
|
#define PFX "SoftMAC: "
|
|
|
|
|
|
|
|
#ifdef assert
|
|
|
|
# undef assert
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_IEEE80211_SOFTMAC_DEBUG
|
|
|
|
#define assert(expr) \
|
|
|
|
do { \
|
|
|
|
if (unlikely(!(expr))) { \
|
|
|
|
printkl(KERN_ERR PFX "ASSERTION FAILED (%s) at: %s:%d:%s()\n", #expr, \
|
|
|
|
__FILE__, __LINE__, __FUNCTION__); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
#else
|
|
|
|
#define assert(expr) do {} while (0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* rate limited printk(). */
|
|
|
|
#ifdef printkl
|
|
|
|
# undef printkl
|
|
|
|
#endif
|
|
|
|
#define printkl(f, x...) do { if (printk_ratelimit()) printk(f ,##x); } while (0)
|
|
|
|
/* rate limited printk() for debugging */
|
|
|
|
#ifdef dprintkl
|
|
|
|
# undef dprintkl
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_IEEE80211_SOFTMAC_DEBUG
|
|
|
|
# define dprintkl printkl
|
|
|
|
#else
|
|
|
|
# define dprintkl(f, x...) do { /* nothing */ } while (0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* debugging printk() */
|
|
|
|
#ifdef dprintk
|
|
|
|
# undef dprintk
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_IEEE80211_SOFTMAC_DEBUG
|
|
|
|
# define dprintk(f, x...) do { printk(f ,##x); } while (0)
|
|
|
|
#else
|
|
|
|
# define dprintk(f, x...) do { /* nothing */ } while (0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* private definitions and prototypes */
|
|
|
|
|
|
|
|
/*** prototypes from _scan.c */
|
2006-11-22 15:57:56 +01:00
|
|
|
void ieee80211softmac_scan(struct work_struct *work);
|
2006-01-04 16:32:16 +01:00
|
|
|
/* for internal use if scanning is needed */
|
|
|
|
int ieee80211softmac_start_scan(struct ieee80211softmac_device *mac);
|
|
|
|
void ieee80211softmac_stop_scan(struct ieee80211softmac_device *mac);
|
|
|
|
void ieee80211softmac_wait_for_scan(struct ieee80211softmac_device *mac);
|
|
|
|
|
|
|
|
/* for use by _module.c to assign to the callbacks */
|
|
|
|
int ieee80211softmac_start_scan_implementation(struct net_device *dev);
|
|
|
|
void ieee80211softmac_stop_scan_implementation(struct net_device *dev);
|
|
|
|
void ieee80211softmac_wait_for_scan_implementation(struct net_device *dev);
|
|
|
|
|
|
|
|
/*** Network prototypes from _module.c */
|
|
|
|
struct ieee80211softmac_network * ieee80211softmac_create_network(
|
|
|
|
struct ieee80211softmac_device *mac, struct ieee80211_network *net);
|
|
|
|
void ieee80211softmac_add_network_locked(struct ieee80211softmac_device *mac,
|
|
|
|
struct ieee80211softmac_network *net);
|
|
|
|
void ieee80211softmac_add_network(struct ieee80211softmac_device *mac,
|
|
|
|
struct ieee80211softmac_network *net);
|
|
|
|
void ieee80211softmac_del_network_locked(struct ieee80211softmac_device *mac,
|
|
|
|
struct ieee80211softmac_network *net);
|
|
|
|
void ieee80211softmac_del_network(struct ieee80211softmac_device *mac,
|
|
|
|
struct ieee80211softmac_network *net);
|
|
|
|
struct ieee80211softmac_network * ieee80211softmac_get_network_by_bssid_locked(
|
|
|
|
struct ieee80211softmac_device *mac, u8 *ea);
|
|
|
|
struct ieee80211softmac_network * ieee80211softmac_get_network_by_bssid(
|
|
|
|
struct ieee80211softmac_device *mac, u8 *ea);
|
|
|
|
struct ieee80211softmac_network * ieee80211softmac_get_network_by_ssid_locked(
|
|
|
|
struct ieee80211softmac_device *mac, u8 *ssid, u8 ssid_len);
|
|
|
|
struct ieee80211softmac_network * ieee80211softmac_get_network_by_ssid(
|
|
|
|
struct ieee80211softmac_device *mac, u8 *ssid, u8 ssid_len);
|
2006-01-04 21:06:28 +01:00
|
|
|
struct ieee80211softmac_network *
|
|
|
|
ieee80211softmac_get_network_by_essid_locked(struct ieee80211softmac_device *mac,
|
|
|
|
struct ieee80211softmac_essid *essid);
|
|
|
|
struct ieee80211softmac_network *
|
|
|
|
ieee80211softmac_get_network_by_essid(struct ieee80211softmac_device *mac,
|
|
|
|
struct ieee80211softmac_essid *essid);
|
2006-01-04 16:32:16 +01:00
|
|
|
|
|
|
|
/* Rates related */
|
2006-07-18 22:33:27 +02:00
|
|
|
void ieee80211softmac_process_erp(struct ieee80211softmac_device *mac,
|
|
|
|
u8 erp_value);
|
2006-05-01 23:45:50 +02:00
|
|
|
int ieee80211softmac_ratesinfo_rate_supported(struct ieee80211softmac_ratesinfo *ri, u8 rate);
|
2006-01-04 16:32:16 +01:00
|
|
|
u8 ieee80211softmac_lower_rate_delta(struct ieee80211softmac_device *mac, u8 rate, int delta);
|
2006-07-18 22:33:27 +02:00
|
|
|
void ieee80211softmac_init_bss(struct ieee80211softmac_device *mac);
|
2006-05-01 23:45:50 +02:00
|
|
|
void ieee80211softmac_recalc_txrates(struct ieee80211softmac_device *mac);
|
2006-01-04 16:32:16 +01:00
|
|
|
static inline u8 lower_rate(struct ieee80211softmac_device *mac, u8 rate) {
|
|
|
|
return ieee80211softmac_lower_rate_delta(mac, rate, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline u8 get_fallback_rate(struct ieee80211softmac_device *mac, u8 rate)
|
|
|
|
{
|
|
|
|
return ieee80211softmac_lower_rate_delta(mac, rate, 2);
|
|
|
|
}
|
2007-02-09 15:24:46 +01:00
|
|
|
|
2006-01-04 16:32:16 +01:00
|
|
|
|
|
|
|
/*** prototypes from _io.c */
|
|
|
|
int ieee80211softmac_send_mgt_frame(struct ieee80211softmac_device *mac,
|
|
|
|
void* ptrarg, u32 type, u32 arg);
|
2006-07-18 22:33:27 +02:00
|
|
|
int ieee80211softmac_handle_beacon(struct net_device *dev,
|
|
|
|
struct ieee80211_beacon *beacon,
|
|
|
|
struct ieee80211_network *network);
|
2006-01-04 16:32:16 +01:00
|
|
|
|
|
|
|
/*** prototypes from _auth.c */
|
|
|
|
/* do these have to go into the public header? */
|
|
|
|
int ieee80211softmac_auth_req(struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net);
|
|
|
|
int ieee80211softmac_deauth_req(struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net, int reason);
|
|
|
|
|
|
|
|
/* for use by _module.c to assign to the callbacks */
|
|
|
|
int ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *auth);
|
2006-01-31 19:48:06 +01:00
|
|
|
int ieee80211softmac_deauth_resp(struct net_device *dev, struct ieee80211_deauth *deauth);
|
2006-01-04 16:32:16 +01:00
|
|
|
|
|
|
|
/*** prototypes from _assoc.c */
|
2006-11-22 15:57:56 +01:00
|
|
|
void ieee80211softmac_assoc_work(struct work_struct *work);
|
2006-01-04 16:32:16 +01:00
|
|
|
int ieee80211softmac_handle_assoc_response(struct net_device * dev,
|
|
|
|
struct ieee80211_assoc_response * resp,
|
|
|
|
struct ieee80211_network * network);
|
|
|
|
int ieee80211softmac_handle_disassoc(struct net_device * dev,
|
|
|
|
struct ieee80211_disassoc * disassoc);
|
2006-01-31 19:49:42 +01:00
|
|
|
int ieee80211softmac_handle_reassoc_req(struct net_device * dev,
|
2007-02-09 15:24:46 +01:00
|
|
|
struct ieee80211_reassoc_request * reassoc);
|
2006-11-22 15:57:56 +01:00
|
|
|
void ieee80211softmac_assoc_timeout(struct work_struct *work);
|
2006-05-01 23:23:27 +02:00
|
|
|
void ieee80211softmac_send_disassoc_req(struct ieee80211softmac_device *mac, u16 reason);
|
|
|
|
void ieee80211softmac_disassoc(struct ieee80211softmac_device *mac);
|
2006-01-04 16:32:16 +01:00
|
|
|
|
|
|
|
/* some helper functions */
|
|
|
|
static inline int ieee80211softmac_scan_handlers_check_self(struct ieee80211softmac_device *sm)
|
|
|
|
{
|
2007-02-09 15:24:46 +01:00
|
|
|
return (sm->start_scan == ieee80211softmac_start_scan_implementation) &&
|
|
|
|
(sm->stop_scan == ieee80211softmac_stop_scan_implementation) &&
|
2006-01-04 16:32:16 +01:00
|
|
|
(sm->wait_for_scan == ieee80211softmac_wait_for_scan_implementation);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int ieee80211softmac_scan_sanity_check(struct ieee80211softmac_device *sm)
|
|
|
|
{
|
2007-02-09 15:24:46 +01:00
|
|
|
return ((sm->start_scan != ieee80211softmac_start_scan_implementation) &&
|
|
|
|
(sm->stop_scan != ieee80211softmac_stop_scan_implementation) &&
|
2006-01-04 16:32:16 +01:00
|
|
|
(sm->wait_for_scan != ieee80211softmac_wait_for_scan_implementation)
|
|
|
|
) || ieee80211softmac_scan_handlers_check_self(sm);
|
|
|
|
}
|
|
|
|
|
2006-03-23 15:00:02 +01:00
|
|
|
#define IEEE80211SOFTMAC_PROBE_DELAY HZ/50
|
2006-01-04 16:32:16 +01:00
|
|
|
#define IEEE80211SOFTMAC_WORKQUEUE_NAME_LEN (17 + IFNAMSIZ)
|
|
|
|
|
|
|
|
struct ieee80211softmac_network {
|
|
|
|
struct list_head list; /* List */
|
|
|
|
/* Network information copied from ieee80211_network */
|
|
|
|
u8 bssid[ETH_ALEN];
|
|
|
|
u8 channel;
|
|
|
|
struct ieee80211softmac_essid essid;
|
|
|
|
|
|
|
|
struct ieee80211softmac_ratesinfo supported_rates;
|
|
|
|
|
|
|
|
/* SoftMAC specific */
|
|
|
|
u16 authenticating:1, /* Status Flags */
|
|
|
|
authenticated:1,
|
|
|
|
auth_desynced_once:1;
|
|
|
|
|
2006-07-18 22:33:27 +02:00
|
|
|
u8 erp_value; /* Saved ERP value */
|
2006-01-04 16:32:16 +01:00
|
|
|
u16 capabilities; /* Capabilities bitfield */
|
|
|
|
u8 challenge_len; /* Auth Challenge length */
|
|
|
|
char *challenge; /* Challenge Text */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* structure used to keep track of networks we're auth'ing to */
|
|
|
|
struct ieee80211softmac_auth_queue_item {
|
|
|
|
struct list_head list; /* List head */
|
|
|
|
struct ieee80211softmac_network *net; /* Network to auth */
|
|
|
|
struct ieee80211softmac_device *mac; /* SoftMAC device */
|
|
|
|
u8 retry; /* Retry limit */
|
|
|
|
u8 state; /* Auth State */
|
2006-11-22 15:57:56 +01:00
|
|
|
struct delayed_work work; /* Work queue */
|
2006-01-04 16:32:16 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/* scanning information */
|
|
|
|
struct ieee80211softmac_scaninfo {
|
|
|
|
u8 current_channel_idx,
|
|
|
|
number_channels;
|
|
|
|
struct ieee80211_channel *channels;
|
|
|
|
u8 started:1,
|
|
|
|
stop:1;
|
|
|
|
u8 skip_flags;
|
|
|
|
struct completion finished;
|
2006-11-22 15:57:56 +01:00
|
|
|
struct delayed_work softmac_scan;
|
|
|
|
struct ieee80211softmac_device *mac;
|
2006-01-04 16:32:16 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/* private event struct */
|
|
|
|
struct ieee80211softmac_event {
|
|
|
|
struct list_head list;
|
|
|
|
int event_type;
|
|
|
|
void *event_context;
|
2006-11-22 15:57:56 +01:00
|
|
|
struct delayed_work work;
|
2006-01-04 16:32:16 +01:00
|
|
|
notify_function_ptr fun;
|
|
|
|
void *context;
|
|
|
|
struct ieee80211softmac_device *mac;
|
|
|
|
};
|
|
|
|
|
|
|
|
void ieee80211softmac_call_events(struct ieee80211softmac_device *mac, int event, void *event_context);
|
|
|
|
void ieee80211softmac_call_events_locked(struct ieee80211softmac_device *mac, int event, void *event_context);
|
|
|
|
int ieee80211softmac_notify_internal(struct ieee80211softmac_device *mac,
|
|
|
|
int event, void *event_context, notify_function_ptr fun, void *context, gfp_t gfp_mask);
|
|
|
|
|
2006-12-03 16:32:00 +01:00
|
|
|
void ieee80211softmac_try_reassoc(struct ieee80211softmac_device *mac);
|
|
|
|
|
2006-01-04 16:32:16 +01:00
|
|
|
#endif /* IEEE80211SOFTMAC_PRIV_H_ */
|