1 #ifndef IEEE80211SOFTMAC_PRIV_H_
2 #define IEEE80211SOFTMAC_PRIV_H_
4 #include <net/ieee80211softmac.h>
5 #include <net/ieee80211softmac_wx.h>
6 #include <linux/kernel.h>
7 #include <linux/stringify.h>
10 #define PFX "SoftMAC: "
15 #ifdef CONFIG_IEEE80211_SOFTMAC_DEBUG
16 #define assert(expr) \
18 if (unlikely(!(expr))) { \
19 printkl(KERN_ERR PFX "ASSERTION FAILED (%s) at: %s:%d:%s()\n", #expr, \
20 __FILE__, __LINE__, __FUNCTION__); \
24 #define assert(expr) do {} while (0)
27 /* rate limited printk(). */
31 #define printkl(f, x...) do { if (printk_ratelimit()) printk(f ,##x); } while (0)
32 /* rate limited printk() for debugging */
36 #ifdef CONFIG_IEEE80211_SOFTMAC_DEBUG
37 # define dprintkl printkl
39 # define dprintkl(f, x...) do { /* nothing */ } while (0)
42 /* debugging printk() */
46 #ifdef CONFIG_IEEE80211_SOFTMAC_DEBUG
47 # define dprintk(f, x...) do { printk(f ,##x); } while (0)
49 # define dprintk(f, x...) do { /* nothing */ } while (0)
53 # undef function_enter
55 #ifdef CONFIG_IEEE80211_SOFTMAC_DEBUG
56 # define function_enter() do { printk(KERN_DEBUG PFX "%s:%d:%s()\n", __FILE__, __LINE__, __FUNCTION__); } while (0)
58 # define function_enter() do { /* nothing */ } while (0)
61 /* private definitions and prototypes */
63 /*** prototypes from _scan.c */
64 void ieee80211softmac_scan(void *sm);
65 /* for internal use if scanning is needed */
66 int ieee80211softmac_start_scan(struct ieee80211softmac_device *mac);
67 void ieee80211softmac_stop_scan(struct ieee80211softmac_device *mac);
68 void ieee80211softmac_wait_for_scan(struct ieee80211softmac_device *mac);
70 /* for use by _module.c to assign to the callbacks */
71 int ieee80211softmac_start_scan_implementation(struct net_device *dev);
72 void ieee80211softmac_stop_scan_implementation(struct net_device *dev);
73 void ieee80211softmac_wait_for_scan_implementation(struct net_device *dev);
75 /*** Network prototypes from _module.c */
76 struct ieee80211softmac_network * ieee80211softmac_create_network(
77 struct ieee80211softmac_device *mac, struct ieee80211_network *net);
78 void ieee80211softmac_add_network_locked(struct ieee80211softmac_device *mac,
79 struct ieee80211softmac_network *net);
80 void ieee80211softmac_add_network(struct ieee80211softmac_device *mac,
81 struct ieee80211softmac_network *net);
82 void ieee80211softmac_del_network_locked(struct ieee80211softmac_device *mac,
83 struct ieee80211softmac_network *net);
84 void ieee80211softmac_del_network(struct ieee80211softmac_device *mac,
85 struct ieee80211softmac_network *net);
86 struct ieee80211softmac_network * ieee80211softmac_get_network_by_bssid_locked(
87 struct ieee80211softmac_device *mac, u8 *ea);
88 struct ieee80211softmac_network * ieee80211softmac_get_network_by_bssid(
89 struct ieee80211softmac_device *mac, u8 *ea);
90 struct ieee80211softmac_network * ieee80211softmac_get_network_by_ssid_locked(
91 struct ieee80211softmac_device *mac, u8 *ssid, u8 ssid_len);
92 struct ieee80211softmac_network * ieee80211softmac_get_network_by_ssid(
93 struct ieee80211softmac_device *mac, u8 *ssid, u8 ssid_len);
97 u8 ieee80211softmac_lower_rate_delta(struct ieee80211softmac_device *mac, u8 rate, int delta);
98 static inline u8 lower_rate(struct ieee80211softmac_device *mac, u8 rate) {
99 return ieee80211softmac_lower_rate_delta(mac, rate, 1);
102 static inline u8 get_fallback_rate(struct ieee80211softmac_device *mac, u8 rate)
104 return ieee80211softmac_lower_rate_delta(mac, rate, 2);
108 /*** prototypes from _io.c */
109 int ieee80211softmac_send_mgt_frame(struct ieee80211softmac_device *mac,
110 void* ptrarg, u32 type, u32 arg);
112 /*** prototypes from _auth.c */
113 /* do these have to go into the public header? */
114 int ieee80211softmac_auth_req(struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net);
115 int ieee80211softmac_deauth_req(struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net, int reason);
117 /* for use by _module.c to assign to the callbacks */
118 int ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *auth);
119 int ieee80211softmac_deauth_resp(struct net_device *dev, struct ieee80211_auth *auth);
121 /*** prototypes from _assoc.c */
122 void ieee80211softmac_assoc_work(void *d);
123 int ieee80211softmac_handle_assoc_response(struct net_device * dev,
124 struct ieee80211_assoc_response * resp,
125 struct ieee80211_network * network);
126 int ieee80211softmac_handle_disassoc(struct net_device * dev,
127 struct ieee80211_disassoc * disassoc);
128 void ieee80211softmac_assoc_timeout(void *d);
130 /* some helper functions */
131 static inline int ieee80211softmac_scan_handlers_check_self(struct ieee80211softmac_device *sm)
133 return (sm->start_scan == ieee80211softmac_start_scan_implementation) &&
134 (sm->stop_scan == ieee80211softmac_stop_scan_implementation) &&
135 (sm->wait_for_scan == ieee80211softmac_wait_for_scan_implementation);
138 static inline int ieee80211softmac_scan_sanity_check(struct ieee80211softmac_device *sm)
140 return ((sm->start_scan != ieee80211softmac_start_scan_implementation) &&
141 (sm->stop_scan != ieee80211softmac_stop_scan_implementation) &&
142 (sm->wait_for_scan != ieee80211softmac_wait_for_scan_implementation)
143 ) || ieee80211softmac_scan_handlers_check_self(sm);
146 #define IEEE80211SOFTMAC_PROBE_DELAY HZ/2
147 #define IEEE80211SOFTMAC_WORKQUEUE_NAME_LEN (17 + IFNAMSIZ)
149 struct ieee80211softmac_network {
150 struct list_head list; /* List */
151 /* Network information copied from ieee80211_network */
154 struct ieee80211softmac_essid essid;
156 struct ieee80211softmac_ratesinfo supported_rates;
158 /* SoftMAC specific */
159 u16 authenticating:1, /* Status Flags */
161 auth_desynced_once:1;
163 u16 capabilities; /* Capabilities bitfield */
164 u8 challenge_len; /* Auth Challenge length */
165 char *challenge; /* Challenge Text */
168 /* structure used to keep track of networks we're auth'ing to */
169 struct ieee80211softmac_auth_queue_item {
170 struct list_head list; /* List head */
171 struct ieee80211softmac_network *net; /* Network to auth */
172 struct ieee80211softmac_device *mac; /* SoftMAC device */
173 u8 retry; /* Retry limit */
174 u8 state; /* Auth State */
175 struct work_struct work; /* Work queue */
178 /* scanning information */
179 struct ieee80211softmac_scaninfo {
180 u8 current_channel_idx,
182 struct ieee80211_channel *channels;
186 struct completion finished;
187 struct work_struct softmac_scan;
190 /* private event struct */
191 struct ieee80211softmac_event {
192 struct list_head list;
195 struct work_struct work;
196 notify_function_ptr fun;
198 struct ieee80211softmac_device *mac;
201 void ieee80211softmac_call_events(struct ieee80211softmac_device *mac, int event, void *event_context);
202 void ieee80211softmac_call_events_locked(struct ieee80211softmac_device *mac, int event, void *event_context);
203 int ieee80211softmac_notify_internal(struct ieee80211softmac_device *mac,
204 int event, void *event_context, notify_function_ptr fun, void *context, gfp_t gfp_mask);
206 #endif /* IEEE80211SOFTMAC_PRIV_H_ */