ieee80211softmac_priv.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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. /* Rates related */
  84. u8 ieee80211softmac_lower_rate_delta(struct ieee80211softmac_device *mac, u8 rate, int delta);
  85. static inline u8 lower_rate(struct ieee80211softmac_device *mac, u8 rate) {
  86. return ieee80211softmac_lower_rate_delta(mac, rate, 1);
  87. }
  88. static inline u8 get_fallback_rate(struct ieee80211softmac_device *mac, u8 rate)
  89. {
  90. return ieee80211softmac_lower_rate_delta(mac, rate, 2);
  91. }
  92. /*** prototypes from _io.c */
  93. int ieee80211softmac_send_mgt_frame(struct ieee80211softmac_device *mac,
  94. void* ptrarg, u32 type, u32 arg);
  95. /*** prototypes from _auth.c */
  96. /* do these have to go into the public header? */
  97. int ieee80211softmac_auth_req(struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net);
  98. int ieee80211softmac_deauth_req(struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net, int reason);
  99. /* for use by _module.c to assign to the callbacks */
  100. int ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *auth);
  101. int ieee80211softmac_deauth_resp(struct net_device *dev, struct ieee80211_auth *auth);
  102. /*** prototypes from _assoc.c */
  103. void ieee80211softmac_assoc_work(void *d);
  104. int ieee80211softmac_handle_assoc_response(struct net_device * dev,
  105. struct ieee80211_assoc_response * resp,
  106. struct ieee80211_network * network);
  107. int ieee80211softmac_handle_disassoc(struct net_device * dev,
  108. struct ieee80211_disassoc * disassoc);
  109. void ieee80211softmac_assoc_timeout(void *d);
  110. /* some helper functions */
  111. static inline int ieee80211softmac_scan_handlers_check_self(struct ieee80211softmac_device *sm)
  112. {
  113. return (sm->start_scan == ieee80211softmac_start_scan_implementation) &&
  114. (sm->stop_scan == ieee80211softmac_stop_scan_implementation) &&
  115. (sm->wait_for_scan == ieee80211softmac_wait_for_scan_implementation);
  116. }
  117. static inline int ieee80211softmac_scan_sanity_check(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. ) || ieee80211softmac_scan_handlers_check_self(sm);
  123. }
  124. #define IEEE80211SOFTMAC_PROBE_DELAY HZ/2
  125. #define IEEE80211SOFTMAC_WORKQUEUE_NAME_LEN (17 + IFNAMSIZ)
  126. struct ieee80211softmac_network {
  127. struct list_head list; /* List */
  128. /* Network information copied from ieee80211_network */
  129. u8 bssid[ETH_ALEN];
  130. u8 channel;
  131. struct ieee80211softmac_essid essid;
  132. struct ieee80211softmac_ratesinfo supported_rates;
  133. /* SoftMAC specific */
  134. u16 authenticating:1, /* Status Flags */
  135. authenticated:1,
  136. auth_desynced_once:1;
  137. u16 capabilities; /* Capabilities bitfield */
  138. u8 challenge_len; /* Auth Challenge length */
  139. char *challenge; /* Challenge Text */
  140. };
  141. /* structure used to keep track of networks we're auth'ing to */
  142. struct ieee80211softmac_auth_queue_item {
  143. struct list_head list; /* List head */
  144. struct ieee80211softmac_network *net; /* Network to auth */
  145. struct ieee80211softmac_device *mac; /* SoftMAC device */
  146. u8 retry; /* Retry limit */
  147. u8 state; /* Auth State */
  148. struct work_struct work; /* Work queue */
  149. };
  150. /* scanning information */
  151. struct ieee80211softmac_scaninfo {
  152. u8 current_channel_idx,
  153. number_channels;
  154. struct ieee80211_channel *channels;
  155. u8 started:1,
  156. stop:1;
  157. u8 skip_flags;
  158. struct completion finished;
  159. struct work_struct softmac_scan;
  160. };
  161. /* private event struct */
  162. struct ieee80211softmac_event {
  163. struct list_head list;
  164. int event_type;
  165. void *event_context;
  166. struct work_struct work;
  167. notify_function_ptr fun;
  168. void *context;
  169. struct ieee80211softmac_device *mac;
  170. };
  171. void ieee80211softmac_call_events(struct ieee80211softmac_device *mac, int event, void *event_context);
  172. void ieee80211softmac_call_events_locked(struct ieee80211softmac_device *mac, int event, void *event_context);
  173. int ieee80211softmac_notify_internal(struct ieee80211softmac_device *mac,
  174. int event, void *event_context, notify_function_ptr fun, void *context, gfp_t gfp_mask);
  175. #endif /* IEEE80211SOFTMAC_PRIV_H_ */