hostap_ap.h 8.1 KB

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