ieee80211softmac_priv.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. /*
  2. * Internal softmac API definitions.
  3. *
  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>
  9. *
  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.
  13. *
  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
  17. * more details.
  18. *
  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
  22. *
  23. * The full GNU General Public License is included in this distribution in the
  24. * file called COPYING.
  25. */
  26. #ifndef IEEE80211SOFTMAC_PRIV_H_
  27. #define IEEE80211SOFTMAC_PRIV_H_
  28. #include <net/ieee80211softmac.h>
  29. #include <net/ieee80211softmac_wx.h>
  30. #include <linux/kernel.h>
  31. #include <linux/stringify.h>
  32. #define PFX "SoftMAC: "
  33. #ifdef assert
  34. # undef assert
  35. #endif
  36. #ifdef CONFIG_IEEE80211_SOFTMAC_DEBUG
  37. #define assert(expr) \
  38. do { \
  39. if (unlikely(!(expr))) { \
  40. printkl(KERN_ERR PFX "ASSERTION FAILED (%s) at: %s:%d:%s()\n", #expr, \
  41. __FILE__, __LINE__, __FUNCTION__); \
  42. } \
  43. } while (0)
  44. #else
  45. #define assert(expr) do {} while (0)
  46. #endif
  47. /* rate limited printk(). */
  48. #ifdef printkl
  49. # undef printkl
  50. #endif
  51. #define printkl(f, x...) do { if (printk_ratelimit()) printk(f ,##x); } while (0)
  52. /* rate limited printk() for debugging */
  53. #ifdef dprintkl
  54. # undef dprintkl
  55. #endif
  56. #ifdef CONFIG_IEEE80211_SOFTMAC_DEBUG
  57. # define dprintkl printkl
  58. #else
  59. # define dprintkl(f, x...) do { /* nothing */ } while (0)
  60. #endif
  61. /* debugging printk() */
  62. #ifdef dprintk
  63. # undef dprintk
  64. #endif
  65. #ifdef CONFIG_IEEE80211_SOFTMAC_DEBUG
  66. # define dprintk(f, x...) do { printk(f ,##x); } while (0)
  67. #else
  68. # define dprintk(f, x...) do { /* nothing */ } while (0)
  69. #endif
  70. /* private definitions and prototypes */
  71. /*** prototypes from _scan.c */
  72. void ieee80211softmac_scan(void *sm);
  73. /* for internal use if scanning is needed */
  74. int ieee80211softmac_start_scan(struct ieee80211softmac_device *mac);
  75. void ieee80211softmac_stop_scan(struct ieee80211softmac_device *mac);
  76. void ieee80211softmac_wait_for_scan(struct ieee80211softmac_device *mac);
  77. /* for use by _module.c to assign to the callbacks */
  78. int ieee80211softmac_start_scan_implementation(struct net_device *dev);
  79. void ieee80211softmac_stop_scan_implementation(struct net_device *dev);
  80. void ieee80211softmac_wait_for_scan_implementation(struct net_device *dev);
  81. /*** Network prototypes from _module.c */
  82. struct ieee80211softmac_network * ieee80211softmac_create_network(
  83. struct ieee80211softmac_device *mac, struct ieee80211_network *net);
  84. void ieee80211softmac_add_network_locked(struct ieee80211softmac_device *mac,
  85. struct ieee80211softmac_network *net);
  86. void ieee80211softmac_add_network(struct ieee80211softmac_device *mac,
  87. struct ieee80211softmac_network *net);
  88. void ieee80211softmac_del_network_locked(struct ieee80211softmac_device *mac,
  89. struct ieee80211softmac_network *net);
  90. void ieee80211softmac_del_network(struct ieee80211softmac_device *mac,
  91. struct ieee80211softmac_network *net);
  92. struct ieee80211softmac_network * ieee80211softmac_get_network_by_bssid_locked(
  93. struct ieee80211softmac_device *mac, u8 *ea);
  94. struct ieee80211softmac_network * ieee80211softmac_get_network_by_bssid(
  95. struct ieee80211softmac_device *mac, u8 *ea);
  96. struct ieee80211softmac_network * ieee80211softmac_get_network_by_ssid_locked(
  97. struct ieee80211softmac_device *mac, u8 *ssid, u8 ssid_len);
  98. struct ieee80211softmac_network * ieee80211softmac_get_network_by_ssid(
  99. struct ieee80211softmac_device *mac, u8 *ssid, u8 ssid_len);
  100. struct ieee80211softmac_network *
  101. ieee80211softmac_get_network_by_essid_locked(struct ieee80211softmac_device *mac,
  102. struct ieee80211softmac_essid *essid);
  103. struct ieee80211softmac_network *
  104. ieee80211softmac_get_network_by_essid(struct ieee80211softmac_device *mac,
  105. struct ieee80211softmac_essid *essid);
  106. /* Rates related */
  107. u8 ieee80211softmac_lower_rate_delta(struct ieee80211softmac_device *mac, u8 rate, int delta);
  108. static inline u8 lower_rate(struct ieee80211softmac_device *mac, u8 rate) {
  109. return ieee80211softmac_lower_rate_delta(mac, rate, 1);
  110. }
  111. static inline u8 get_fallback_rate(struct ieee80211softmac_device *mac, u8 rate)
  112. {
  113. return ieee80211softmac_lower_rate_delta(mac, rate, 2);
  114. }
  115. /*** prototypes from _io.c */
  116. int ieee80211softmac_send_mgt_frame(struct ieee80211softmac_device *mac,
  117. void* ptrarg, u32 type, u32 arg);
  118. /*** prototypes from _auth.c */
  119. /* do these have to go into the public header? */
  120. int ieee80211softmac_auth_req(struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net);
  121. 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_deauth *deauth);
  125. /*** prototypes from _assoc.c */
  126. void ieee80211softmac_assoc_work(void *d);
  127. int ieee80211softmac_handle_assoc_response(struct net_device * dev,
  128. struct ieee80211_assoc_response * resp,
  129. struct ieee80211_network * network);
  130. int ieee80211softmac_handle_disassoc(struct net_device * dev,
  131. struct ieee80211_disassoc * disassoc);
  132. int ieee80211softmac_handle_reassoc_req(struct net_device * dev,
  133. struct ieee80211_reassoc_request * reassoc);
  134. void ieee80211softmac_assoc_timeout(void *d);
  135. /* some helper functions */
  136. static inline int ieee80211softmac_scan_handlers_check_self(struct ieee80211softmac_device *sm)
  137. {
  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);
  141. }
  142. static inline int ieee80211softmac_scan_sanity_check(struct ieee80211softmac_device *sm)
  143. {
  144. return ((sm->start_scan != ieee80211softmac_start_scan_implementation) &&
  145. (sm->stop_scan != ieee80211softmac_stop_scan_implementation) &&
  146. (sm->wait_for_scan != ieee80211softmac_wait_for_scan_implementation)
  147. ) || ieee80211softmac_scan_handlers_check_self(sm);
  148. }
  149. #define IEEE80211SOFTMAC_PROBE_DELAY HZ/50
  150. #define IEEE80211SOFTMAC_WORKQUEUE_NAME_LEN (17 + IFNAMSIZ)
  151. struct ieee80211softmac_network {
  152. struct list_head list; /* List */
  153. /* Network information copied from ieee80211_network */
  154. u8 bssid[ETH_ALEN];
  155. u8 channel;
  156. struct ieee80211softmac_essid essid;
  157. struct ieee80211softmac_ratesinfo supported_rates;
  158. /* SoftMAC specific */
  159. u16 authenticating:1, /* Status Flags */
  160. authenticated:1,
  161. auth_desynced_once:1;
  162. u16 capabilities; /* Capabilities bitfield */
  163. u8 challenge_len; /* Auth Challenge length */
  164. char *challenge; /* Challenge Text */
  165. };
  166. /* structure used to keep track of networks we're auth'ing to */
  167. struct ieee80211softmac_auth_queue_item {
  168. struct list_head list; /* List head */
  169. struct ieee80211softmac_network *net; /* Network to auth */
  170. struct ieee80211softmac_device *mac; /* SoftMAC device */
  171. u8 retry; /* Retry limit */
  172. u8 state; /* Auth State */
  173. struct work_struct work; /* Work queue */
  174. };
  175. /* scanning information */
  176. struct ieee80211softmac_scaninfo {
  177. u8 current_channel_idx,
  178. number_channels;
  179. struct ieee80211_channel *channels;
  180. u8 started:1,
  181. stop:1;
  182. u8 skip_flags;
  183. struct completion finished;
  184. struct work_struct softmac_scan;
  185. };
  186. /* private event struct */
  187. struct ieee80211softmac_event {
  188. struct list_head list;
  189. int event_type;
  190. void *event_context;
  191. struct work_struct work;
  192. notify_function_ptr fun;
  193. void *context;
  194. struct ieee80211softmac_device *mac;
  195. };
  196. void ieee80211softmac_call_events(struct ieee80211softmac_device *mac, int event, void *event_context);
  197. void ieee80211softmac_call_events_locked(struct ieee80211softmac_device *mac, int event, void *event_context);
  198. int ieee80211softmac_notify_internal(struct ieee80211softmac_device *mac,
  199. int event, void *event_context, notify_function_ptr fun, void *context, gfp_t gfp_mask);
  200. #endif /* IEEE80211SOFTMAC_PRIV_H_ */