ieee80211softmac_priv.h 7.5 KB

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