hostap_ap.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. #ifndef HOSTAP_AP_H
  2. #define HOSTAP_AP_H
  3. /* AP data structures for STAs */
  4. /* maximum number of frames to buffer per STA */
  5. #define STA_MAX_TX_BUFFER 32
  6. /* Flags used in skb->cb[6] to control how the packet is handled in TX path.
  7. * skb->cb[0..5] must contain magic value 'hostap' to indicate that cb[6] is
  8. * used. */
  9. #define AP_SKB_CB_MAGIC "hostap"
  10. #define AP_SKB_CB_MAGIC_LEN 6
  11. #define AP_SKB_CB_BUFFERED_FRAME BIT(0)
  12. #define AP_SKB_CB_ADD_MOREDATA BIT(1)
  13. /* STA flags */
  14. #define WLAN_STA_AUTH BIT(0)
  15. #define WLAN_STA_ASSOC BIT(1)
  16. #define WLAN_STA_PS BIT(2)
  17. #define WLAN_STA_TIM BIT(3) /* TIM bit is on for PS stations */
  18. #define WLAN_STA_PERM BIT(4) /* permanent; do not remove entry on expiration */
  19. #define WLAN_STA_AUTHORIZED BIT(5) /* If 802.1X is used, this flag is
  20. * controlling whether STA is authorized to
  21. * send and receive non-IEEE 802.1X frames
  22. */
  23. #define WLAN_STA_PENDING_POLL BIT(6) /* pending activity poll not ACKed */
  24. #define WLAN_RATE_1M BIT(0)
  25. #define WLAN_RATE_2M BIT(1)
  26. #define WLAN_RATE_5M5 BIT(2)
  27. #define WLAN_RATE_11M BIT(3)
  28. #define WLAN_RATE_COUNT 4
  29. /* Maximum size of Supported Rates info element. IEEE 802.11 has a limit of 8,
  30. * but some pre-standard IEEE 802.11g products use longer elements. */
  31. #define WLAN_SUPP_RATES_MAX 32
  32. /* Try to increase TX rate after # successfully sent consecutive packets */
  33. #define WLAN_RATE_UPDATE_COUNT 50
  34. /* Decrease TX rate after # consecutive dropped packets */
  35. #define WLAN_RATE_DECREASE_THRESHOLD 2
  36. struct sta_info {
  37. struct list_head list;
  38. struct sta_info *hnext; /* next entry in hash table list */
  39. atomic_t users; /* number of users (do not remove if > 0) */
  40. struct proc_dir_entry *proc;
  41. u8 addr[6];
  42. u16 aid; /* STA's unique AID (1 .. 2007) or 0 if not yet assigned */
  43. u32 flags;
  44. u16 capability;
  45. u16 listen_interval; /* or beacon_int for APs */
  46. u8 supported_rates[WLAN_SUPP_RATES_MAX];
  47. unsigned long last_auth;
  48. unsigned long last_assoc;
  49. unsigned long last_rx;
  50. unsigned long last_tx;
  51. unsigned long rx_packets, tx_packets;
  52. unsigned long rx_bytes, tx_bytes;
  53. struct sk_buff_head tx_buf;
  54. /* FIX: timeout buffers with an expiry time somehow derived from
  55. * listen_interval */
  56. s8 last_rx_silence; /* Noise in dBm */
  57. s8 last_rx_signal; /* Signal strength in dBm */
  58. u8 last_rx_rate; /* TX rate in 0.1 Mbps */
  59. u8 last_rx_updated; /* IWSPY's struct iw_quality::updated */
  60. u8 tx_supp_rates; /* bit field of supported TX rates */
  61. u8 tx_rate; /* current TX rate (in 0.1 Mbps) */
  62. u8 tx_rate_idx; /* current TX rate (WLAN_RATE_*) */
  63. u8 tx_max_rate; /* max TX rate (WLAN_RATE_*) */
  64. u32 tx_count[WLAN_RATE_COUNT]; /* number of frames sent (per rate) */
  65. u32 rx_count[WLAN_RATE_COUNT]; /* number of frames received (per rate)
  66. */
  67. u32 tx_since_last_failure;
  68. u32 tx_consecutive_exc;
  69. struct prism2_crypt_data *crypt;
  70. int ap; /* whether this station is an AP */
  71. local_info_t *local;
  72. #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
  73. union {
  74. struct {
  75. char *challenge; /* shared key authentication
  76. * challenge */
  77. } sta;
  78. struct {
  79. int ssid_len;
  80. unsigned char ssid[MAX_SSID_LEN + 1]; /* AP's ssid */
  81. int channel;
  82. unsigned long last_beacon; /* last RX beacon time */
  83. } ap;
  84. } u;
  85. struct timer_list timer;
  86. enum { STA_NULLFUNC = 0, STA_DISASSOC, STA_DEAUTH } timeout_next;
  87. #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
  88. };
  89. #define MAX_STA_COUNT 1024
  90. /* Maximum number of AIDs to use for STAs; must be 2007 or lower
  91. * (8802.11 limitation) */
  92. #define MAX_AID_TABLE_SIZE 128
  93. #define STA_HASH_SIZE 256
  94. #define STA_HASH(sta) (sta[5])
  95. /* Default value for maximum station inactivity. After AP_MAX_INACTIVITY_SEC
  96. * has passed since last received frame from the station, a nullfunc data
  97. * frame is sent to the station. If this frame is not acknowledged and no other
  98. * frames have been received, the station will be disassociated after
  99. * AP_DISASSOC_DELAY. Similarily, a the station will be deauthenticated after
  100. * AP_DEAUTH_DELAY. AP_TIMEOUT_RESOLUTION is the resolution that is used with
  101. * max inactivity timer. */
  102. #define AP_MAX_INACTIVITY_SEC (5 * 60)
  103. #define AP_DISASSOC_DELAY (HZ)
  104. #define AP_DEAUTH_DELAY (HZ)
  105. /* ap_policy: whether to accept frames to/from other APs/IBSS */
  106. typedef enum {
  107. AP_OTHER_AP_SKIP_ALL = 0,
  108. AP_OTHER_AP_SAME_SSID = 1,
  109. AP_OTHER_AP_ALL = 2,
  110. AP_OTHER_AP_EVEN_IBSS = 3
  111. } ap_policy_enum;
  112. #define PRISM2_AUTH_OPEN BIT(0)
  113. #define PRISM2_AUTH_SHARED_KEY BIT(1)
  114. /* MAC address-based restrictions */
  115. struct mac_entry {
  116. struct list_head list;
  117. u8 addr[6];
  118. };
  119. struct mac_restrictions {
  120. enum { MAC_POLICY_OPEN = 0, MAC_POLICY_ALLOW, MAC_POLICY_DENY } policy;
  121. unsigned int entries;
  122. struct list_head mac_list;
  123. spinlock_t lock;
  124. };
  125. struct add_sta_proc_data {
  126. u8 addr[ETH_ALEN];
  127. struct add_sta_proc_data *next;
  128. };
  129. typedef enum { WDS_ADD, WDS_DEL } wds_oper_type;
  130. struct wds_oper_data {
  131. wds_oper_type type;
  132. u8 addr[ETH_ALEN];
  133. struct wds_oper_data *next;
  134. };
  135. struct ap_data {
  136. int initialized; /* whether ap_data has been initialized */
  137. local_info_t *local;
  138. int bridge_packets; /* send packet to associated STAs directly to the
  139. * wireless media instead of higher layers in the
  140. * kernel */
  141. unsigned int bridged_unicast; /* number of unicast frames bridged on
  142. * wireless media */
  143. unsigned int bridged_multicast; /* number of non-unicast frames
  144. * bridged on wireless media */
  145. unsigned int tx_drop_nonassoc; /* number of unicast TX packets dropped
  146. * because they were to an address that
  147. * was not associated */
  148. int nullfunc_ack; /* use workaround for nullfunc frame ACKs */
  149. spinlock_t sta_table_lock;
  150. int num_sta; /* number of entries in sta_list */
  151. struct list_head sta_list; /* STA info list head */
  152. struct sta_info *sta_hash[STA_HASH_SIZE];
  153. struct proc_dir_entry *proc;
  154. ap_policy_enum ap_policy;
  155. unsigned int max_inactivity;
  156. int autom_ap_wds;
  157. struct mac_restrictions mac_restrictions; /* MAC-based auth */
  158. int last_tx_rate;
  159. struct work_struct add_sta_proc_queue;
  160. struct add_sta_proc_data *add_sta_proc_entries;
  161. struct work_struct wds_oper_queue;
  162. struct wds_oper_data *wds_oper_entries;
  163. u16 tx_callback_idx;
  164. #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
  165. /* pointers to STA info; based on allocated AID or NULL if AID free
  166. * AID is in the range 1-2007, so sta_aid[0] corresponders to AID 1
  167. * and so on
  168. */
  169. struct sta_info *sta_aid[MAX_AID_TABLE_SIZE];
  170. u16 tx_callback_auth, tx_callback_assoc, tx_callback_poll;
  171. /* WEP operations for generating challenges to be used with shared key
  172. * authentication */
  173. struct hostap_crypto_ops *crypt;
  174. void *crypt_priv;
  175. #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
  176. };
  177. void hostap_rx(struct net_device *dev, struct sk_buff *skb,
  178. struct hostap_80211_rx_status *rx_stats);
  179. void hostap_init_data(local_info_t *local);
  180. void hostap_init_ap_proc(local_info_t *local);
  181. void hostap_free_data(struct ap_data *ap);
  182. void hostap_check_sta_fw_version(struct ap_data *ap, int sta_fw_ver);
  183. typedef enum {
  184. AP_TX_CONTINUE, AP_TX_DROP, AP_TX_RETRY, AP_TX_BUFFERED,
  185. AP_TX_CONTINUE_NOT_AUTHORIZED
  186. } ap_tx_ret;
  187. struct hostap_tx_data {
  188. struct sk_buff *skb;
  189. int host_encrypt;
  190. struct prism2_crypt_data *crypt;
  191. void *sta_ptr;
  192. };
  193. ap_tx_ret hostap_handle_sta_tx(local_info_t *local, struct hostap_tx_data *tx);
  194. void hostap_handle_sta_release(void *ptr);
  195. void hostap_handle_sta_tx_exc(local_info_t *local, struct sk_buff *skb);
  196. int hostap_update_sta_ps(local_info_t *local,
  197. struct hostap_ieee80211_hdr *hdr);
  198. typedef enum {
  199. AP_RX_CONTINUE, AP_RX_DROP, AP_RX_EXIT, AP_RX_CONTINUE_NOT_AUTHORIZED
  200. } ap_rx_ret;
  201. ap_rx_ret hostap_handle_sta_rx(local_info_t *local, struct net_device *dev,
  202. struct sk_buff *skb,
  203. struct hostap_80211_rx_status *rx_stats,
  204. int wds);
  205. int hostap_handle_sta_crypto(local_info_t *local,
  206. struct hostap_ieee80211_hdr *hdr,
  207. struct prism2_crypt_data **crypt, void **sta_ptr);
  208. int hostap_is_sta_assoc(struct ap_data *ap, u8 *sta_addr);
  209. int hostap_is_sta_authorized(struct ap_data *ap, u8 *sta_addr);
  210. int hostap_add_sta(struct ap_data *ap, u8 *sta_addr);
  211. int hostap_update_rx_stats(struct ap_data *ap,
  212. struct hostap_ieee80211_hdr *hdr,
  213. struct hostap_80211_rx_status *rx_stats);
  214. void hostap_update_rates(local_info_t *local);
  215. void hostap_add_wds_links(local_info_t *local);
  216. void hostap_wds_link_oper(local_info_t *local, u8 *addr, wds_oper_type type);
  217. #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
  218. void hostap_deauth_all_stas(struct net_device *dev, struct ap_data *ap,
  219. int resend);
  220. #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
  221. #endif /* HOSTAP_AP_H */