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);
94 struct ieee80211softmac_network *
95 ieee80211softmac_get_network_by_essid_locked(struct ieee80211softmac_device *mac,
96 struct ieee80211softmac_essid *essid);
97 struct ieee80211softmac_network *
98 ieee80211softmac_get_network_by_essid(struct ieee80211softmac_device *mac,
99 struct ieee80211softmac_essid *essid);
102 u8 ieee80211softmac_lower_rate_delta(struct ieee80211softmac_device *mac, u8 rate, int delta);
103 static inline u8 lower_rate(struct ieee80211softmac_device *mac, u8 rate) {
104 return ieee80211softmac_lower_rate_delta(mac, rate, 1);
107 static inline u8 get_fallback_rate(struct ieee80211softmac_device *mac, u8 rate)
109 return ieee80211softmac_lower_rate_delta(mac, rate, 2);
113 /*** prototypes from _io.c */
114 int ieee80211softmac_send_mgt_frame(struct ieee80211softmac_device *mac,
115 void* ptrarg, u32 type, u32 arg);
117 /*** prototypes from _auth.c */
118 /* do these have to go into the public header? */
119 int ieee80211softmac_auth_req(struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net);
120 int ieee80211softmac_deauth_req(struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net, int reason);
122 /* for use by _module.c to assign to the callbacks */
123 int ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *auth);
124 int ieee80211softmac_deauth_resp(struct net_device *dev, struct ieee80211_auth *auth);
126 /*** prototypes from _assoc.c */
127 void ieee80211softmac_assoc_work(void *d);
128 int ieee80211softmac_handle_assoc_response(struct net_device * dev,
129 struct ieee80211_assoc_response * resp,
130 struct ieee80211_network * network);
131 int ieee80211softmac_handle_disassoc(struct net_device * dev,
132 struct ieee80211_disassoc * disassoc);
133 void ieee80211softmac_assoc_timeout(void *d);
135 /* some helper functions */
136 static inline int ieee80211softmac_scan_handlers_check_self(struct ieee80211softmac_device *sm)
138 return (sm->start_scan == ieee80211softmac_start_scan_implementation) &&
139 (sm->stop_scan == ieee80211softmac_stop_scan_implementation) &&
140 (sm->wait_for_scan == ieee80211softmac_wait_for_scan_implementation);
143 static inline int ieee80211softmac_scan_sanity_check(struct ieee80211softmac_device *sm)
145 return ((sm->start_scan != ieee80211softmac_start_scan_implementation) &&
146 (sm->stop_scan != ieee80211softmac_stop_scan_implementation) &&
147 (sm->wait_for_scan != ieee80211softmac_wait_for_scan_implementation)
148 ) || ieee80211softmac_scan_handlers_check_self(sm);
151 #define IEEE80211SOFTMAC_PROBE_DELAY HZ/2
152 #define IEEE80211SOFTMAC_WORKQUEUE_NAME_LEN (17 + IFNAMSIZ)
154 struct ieee80211softmac_network {
155 struct list_head list; /* List */
156 /* Network information copied from ieee80211_network */
159 struct ieee80211softmac_essid essid;
161 struct ieee80211softmac_ratesinfo supported_rates;
163 /* SoftMAC specific */
164 u16 authenticating:1, /* Status Flags */
166 auth_desynced_once:1;
168 u16 capabilities; /* Capabilities bitfield */
169 u8 challenge_len; /* Auth Challenge length */
170 char *challenge; /* Challenge Text */
173 /* structure used to keep track of networks we're auth'ing to */
174 struct ieee80211softmac_auth_queue_item {
175 struct list_head list; /* List head */
176 struct ieee80211softmac_network *net; /* Network to auth */
177 struct ieee80211softmac_device *mac; /* SoftMAC device */
178 u8 retry; /* Retry limit */
179 u8 state; /* Auth State */
180 struct work_struct work; /* Work queue */
183 /* scanning information */
184 struct ieee80211softmac_scaninfo {
185 u8 current_channel_idx,
187 struct ieee80211_channel *channels;
191 struct completion finished;
192 struct work_struct softmac_scan;
195 /* private event struct */
196 struct ieee80211softmac_event {
197 struct list_head list;
200 struct work_struct work;
201 notify_function_ptr fun;
203 struct ieee80211softmac_device *mac;
206 void ieee80211softmac_call_events(struct ieee80211softmac_device *mac, int event, void *event_context);
207 void ieee80211softmac_call_events_locked(struct ieee80211softmac_device *mac, int event, void *event_context);
208 int ieee80211softmac_notify_internal(struct ieee80211softmac_device *mac,
209 int event, void *event_context, notify_function_ptr fun, void *context, gfp_t gfp_mask);
211 #endif /* IEEE80211SOFTMAC_PRIV_H_ */