2 * Internal softmac API definitions.
4 * Copyright (c) 2005, 2006 Johannes Berg <johannes@sipsolutions.net>
5 * Joseph Jezak <josejx@gentoo.org>
6 * Larry Finger <Larry.Finger@lwfinger.net>
7 * Danny van Dyk <kugelfang@gentoo.org>
8 * Michael Buesch <mbuesch@freenet.de>
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of version 2 of the GNU General Public License as
12 * published by the Free Software Foundation.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 * The full GNU General Public License is included in this distribution in the
24 * file called COPYING.
27 #ifndef IEEE80211SOFTMAC_PRIV_H_
28 #define IEEE80211SOFTMAC_PRIV_H_
30 #include <net/ieee80211softmac.h>
31 #include <net/ieee80211softmac_wx.h>
32 #include <linux/kernel.h>
33 #include <linux/stringify.h>
36 #define PFX "SoftMAC: "
41 #ifdef CONFIG_IEEE80211_SOFTMAC_DEBUG
42 #define assert(expr) \
44 if (unlikely(!(expr))) { \
45 printkl(KERN_ERR PFX "ASSERTION FAILED (%s) at: %s:%d:%s()\n", #expr, \
46 __FILE__, __LINE__, __FUNCTION__); \
50 #define assert(expr) do {} while (0)
53 /* rate limited printk(). */
57 #define printkl(f, x...) do { if (printk_ratelimit()) printk(f ,##x); } while (0)
58 /* rate limited printk() for debugging */
62 #ifdef CONFIG_IEEE80211_SOFTMAC_DEBUG
63 # define dprintkl printkl
65 # define dprintkl(f, x...) do { /* nothing */ } while (0)
68 /* debugging printk() */
72 #ifdef CONFIG_IEEE80211_SOFTMAC_DEBUG
73 # define dprintk(f, x...) do { printk(f ,##x); } while (0)
75 # define dprintk(f, x...) do { /* nothing */ } while (0)
78 /* private definitions and prototypes */
80 /*** prototypes from _scan.c */
81 void ieee80211softmac_scan(void *sm
);
82 /* for internal use if scanning is needed */
83 int ieee80211softmac_start_scan(struct ieee80211softmac_device
*mac
);
84 void ieee80211softmac_stop_scan(struct ieee80211softmac_device
*mac
);
85 void ieee80211softmac_wait_for_scan(struct ieee80211softmac_device
*mac
);
87 /* for use by _module.c to assign to the callbacks */
88 int ieee80211softmac_start_scan_implementation(struct net_device
*dev
);
89 void ieee80211softmac_stop_scan_implementation(struct net_device
*dev
);
90 void ieee80211softmac_wait_for_scan_implementation(struct net_device
*dev
);
92 /*** Network prototypes from _module.c */
93 struct ieee80211softmac_network
* ieee80211softmac_create_network(
94 struct ieee80211softmac_device
*mac
, struct ieee80211_network
*net
);
95 void ieee80211softmac_add_network_locked(struct ieee80211softmac_device
*mac
,
96 struct ieee80211softmac_network
*net
);
97 void ieee80211softmac_add_network(struct ieee80211softmac_device
*mac
,
98 struct ieee80211softmac_network
*net
);
99 void ieee80211softmac_del_network_locked(struct ieee80211softmac_device
*mac
,
100 struct ieee80211softmac_network
*net
);
101 void ieee80211softmac_del_network(struct ieee80211softmac_device
*mac
,
102 struct ieee80211softmac_network
*net
);
103 struct ieee80211softmac_network
* ieee80211softmac_get_network_by_bssid_locked(
104 struct ieee80211softmac_device
*mac
, u8
*ea
);
105 struct ieee80211softmac_network
* ieee80211softmac_get_network_by_bssid(
106 struct ieee80211softmac_device
*mac
, u8
*ea
);
107 struct ieee80211softmac_network
* ieee80211softmac_get_network_by_ssid_locked(
108 struct ieee80211softmac_device
*mac
, u8
*ssid
, u8 ssid_len
);
109 struct ieee80211softmac_network
* ieee80211softmac_get_network_by_ssid(
110 struct ieee80211softmac_device
*mac
, u8
*ssid
, u8 ssid_len
);
111 struct ieee80211softmac_network
*
112 ieee80211softmac_get_network_by_essid_locked(struct ieee80211softmac_device
*mac
,
113 struct ieee80211softmac_essid
*essid
);
114 struct ieee80211softmac_network
*
115 ieee80211softmac_get_network_by_essid(struct ieee80211softmac_device
*mac
,
116 struct ieee80211softmac_essid
*essid
);
119 int ieee80211softmac_ratesinfo_rate_supported(struct ieee80211softmac_ratesinfo
*ri
, u8 rate
);
120 u8
ieee80211softmac_lower_rate_delta(struct ieee80211softmac_device
*mac
, u8 rate
, int delta
);
121 void ieee80211softmac_init_txrates(struct ieee80211softmac_device
*mac
);
122 void ieee80211softmac_recalc_txrates(struct ieee80211softmac_device
*mac
);
123 static inline u8
lower_rate(struct ieee80211softmac_device
*mac
, u8 rate
) {
124 return ieee80211softmac_lower_rate_delta(mac
, rate
, 1);
127 static inline u8
get_fallback_rate(struct ieee80211softmac_device
*mac
, u8 rate
)
129 return ieee80211softmac_lower_rate_delta(mac
, rate
, 2);
133 /*** prototypes from _io.c */
134 int ieee80211softmac_send_mgt_frame(struct ieee80211softmac_device
*mac
,
135 void* ptrarg
, u32 type
, u32 arg
);
137 /*** prototypes from _auth.c */
138 /* do these have to go into the public header? */
139 int ieee80211softmac_auth_req(struct ieee80211softmac_device
*mac
, struct ieee80211softmac_network
*net
);
140 int ieee80211softmac_deauth_req(struct ieee80211softmac_device
*mac
, struct ieee80211softmac_network
*net
, int reason
);
142 /* for use by _module.c to assign to the callbacks */
143 int ieee80211softmac_auth_resp(struct net_device
*dev
, struct ieee80211_auth
*auth
);
144 int ieee80211softmac_deauth_resp(struct net_device
*dev
, struct ieee80211_deauth
*deauth
);
146 /*** prototypes from _assoc.c */
147 void ieee80211softmac_assoc_work(void *d
);
148 int ieee80211softmac_handle_assoc_response(struct net_device
* dev
,
149 struct ieee80211_assoc_response
* resp
,
150 struct ieee80211_network
* network
);
151 int ieee80211softmac_handle_disassoc(struct net_device
* dev
,
152 struct ieee80211_disassoc
* disassoc
);
153 int ieee80211softmac_handle_reassoc_req(struct net_device
* dev
,
154 struct ieee80211_reassoc_request
* reassoc
);
155 void ieee80211softmac_assoc_timeout(void *d
);
156 void ieee80211softmac_send_disassoc_req(struct ieee80211softmac_device
*mac
, u16 reason
);
157 void ieee80211softmac_disassoc(struct ieee80211softmac_device
*mac
);
159 /* some helper functions */
160 static inline int ieee80211softmac_scan_handlers_check_self(struct ieee80211softmac_device
*sm
)
162 return (sm
->start_scan
== ieee80211softmac_start_scan_implementation
) &&
163 (sm
->stop_scan
== ieee80211softmac_stop_scan_implementation
) &&
164 (sm
->wait_for_scan
== ieee80211softmac_wait_for_scan_implementation
);
167 static inline int ieee80211softmac_scan_sanity_check(struct ieee80211softmac_device
*sm
)
169 return ((sm
->start_scan
!= ieee80211softmac_start_scan_implementation
) &&
170 (sm
->stop_scan
!= ieee80211softmac_stop_scan_implementation
) &&
171 (sm
->wait_for_scan
!= ieee80211softmac_wait_for_scan_implementation
)
172 ) || ieee80211softmac_scan_handlers_check_self(sm
);
175 #define IEEE80211SOFTMAC_PROBE_DELAY HZ/50
176 #define IEEE80211SOFTMAC_WORKQUEUE_NAME_LEN (17 + IFNAMSIZ)
178 struct ieee80211softmac_network
{
179 struct list_head list
; /* List */
180 /* Network information copied from ieee80211_network */
183 struct ieee80211softmac_essid essid
;
185 struct ieee80211softmac_ratesinfo supported_rates
;
187 /* SoftMAC specific */
188 u16 authenticating
:1, /* Status Flags */
190 auth_desynced_once
:1;
192 u16 capabilities
; /* Capabilities bitfield */
193 u8 challenge_len
; /* Auth Challenge length */
194 char *challenge
; /* Challenge Text */
197 /* structure used to keep track of networks we're auth'ing to */
198 struct ieee80211softmac_auth_queue_item
{
199 struct list_head list
; /* List head */
200 struct ieee80211softmac_network
*net
; /* Network to auth */
201 struct ieee80211softmac_device
*mac
; /* SoftMAC device */
202 u8 retry
; /* Retry limit */
203 u8 state
; /* Auth State */
204 struct work_struct work
; /* Work queue */
207 /* scanning information */
208 struct ieee80211softmac_scaninfo
{
209 u8 current_channel_idx
,
211 struct ieee80211_channel
*channels
;
215 struct completion finished
;
216 struct work_struct softmac_scan
;
219 /* private event struct */
220 struct ieee80211softmac_event
{
221 struct list_head list
;
224 struct work_struct work
;
225 notify_function_ptr fun
;
227 struct ieee80211softmac_device
*mac
;
230 void ieee80211softmac_call_events(struct ieee80211softmac_device
*mac
, int event
, void *event_context
);
231 void ieee80211softmac_call_events_locked(struct ieee80211softmac_device
*mac
, int event
, void *event_context
);
232 int ieee80211softmac_notify_internal(struct ieee80211softmac_device
*mac
,
233 int event
, void *event_context
, notify_function_ptr fun
, void *context
, gfp_t gfp_mask
);
235 #endif /* IEEE80211SOFTMAC_PRIV_H_ */