hostap_ap.h 8.1 KB

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