sta_info.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /*
  2. * hostapd / Station table
  3. * Copyright (c) 2002-2011, Jouni Malinen <j@w1.fi>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. * Alternatively, this software may be distributed under the terms of BSD
  10. * license.
  11. *
  12. * See README and COPYING for more details.
  13. */
  14. #ifndef STA_INFO_H
  15. #define STA_INFO_H
  16. /* STA flags */
  17. #define WLAN_STA_AUTH BIT(0)
  18. #define WLAN_STA_ASSOC BIT(1)
  19. #define WLAN_STA_PS BIT(2)
  20. #define WLAN_STA_TIM BIT(3)
  21. #define WLAN_STA_PERM BIT(4)
  22. #define WLAN_STA_AUTHORIZED BIT(5)
  23. #define WLAN_STA_PENDING_POLL BIT(6) /* pending activity poll not ACKed */
  24. #define WLAN_STA_SHORT_PREAMBLE BIT(7)
  25. #define WLAN_STA_PREAUTH BIT(8)
  26. #define WLAN_STA_WMM BIT(9)
  27. #define WLAN_STA_MFP BIT(10)
  28. #define WLAN_STA_HT BIT(11)
  29. #define WLAN_STA_WPS BIT(12)
  30. #define WLAN_STA_MAYBE_WPS BIT(13)
  31. #define WLAN_STA_WDS BIT(14)
  32. #define WLAN_STA_ASSOC_REQ_OK BIT(15)
  33. #define WLAN_STA_WPS2 BIT(16)
  34. #define WLAN_STA_PENDING_DISASSOC_CB BIT(29)
  35. #define WLAN_STA_PENDING_DEAUTH_CB BIT(30)
  36. #define WLAN_STA_NONERP BIT(31)
  37. /* Maximum number of supported rates (from both Supported Rates and Extended
  38. * Supported Rates IEs). */
  39. #define WLAN_SUPP_RATES_MAX 32
  40. struct sta_info {
  41. struct sta_info *next; /* next entry in sta list */
  42. struct sta_info *hnext; /* next entry in hash table list */
  43. u8 addr[6];
  44. u16 aid; /* STA's unique AID (1 .. 2007) or 0 if not yet assigned */
  45. u32 flags; /* Bitfield of WLAN_STA_* */
  46. u16 capability;
  47. u16 listen_interval; /* or beacon_int for APs */
  48. u8 supported_rates[WLAN_SUPP_RATES_MAX];
  49. int supported_rates_len;
  50. unsigned int nonerp_set:1;
  51. unsigned int no_short_slot_time_set:1;
  52. unsigned int no_short_preamble_set:1;
  53. unsigned int no_ht_gf_set:1;
  54. unsigned int no_ht_set:1;
  55. unsigned int ht_20mhz_set:1;
  56. unsigned int no_p2p_set:1;
  57. u16 auth_alg;
  58. u8 previous_ap[6];
  59. enum {
  60. STA_NULLFUNC = 0, STA_DISASSOC, STA_DEAUTH, STA_REMOVE
  61. } timeout_next;
  62. u16 deauth_reason;
  63. u16 disassoc_reason;
  64. /* IEEE 802.1X related data */
  65. struct eapol_state_machine *eapol_sm;
  66. /* IEEE 802.11f (IAPP) related data */
  67. struct ieee80211_mgmt *last_assoc_req;
  68. u32 acct_session_id_hi;
  69. u32 acct_session_id_lo;
  70. time_t acct_session_start;
  71. int acct_session_started;
  72. int acct_terminate_cause; /* Acct-Terminate-Cause */
  73. int acct_interim_interval; /* Acct-Interim-Interval */
  74. unsigned long last_rx_bytes;
  75. unsigned long last_tx_bytes;
  76. u32 acct_input_gigawords; /* Acct-Input-Gigawords */
  77. u32 acct_output_gigawords; /* Acct-Output-Gigawords */
  78. u8 *challenge; /* IEEE 802.11 Shared Key Authentication Challenge */
  79. struct wpa_state_machine *wpa_sm;
  80. struct rsn_preauth_interface *preauth_iface;
  81. struct hostapd_ssid *ssid; /* SSID selection based on (Re)AssocReq */
  82. struct hostapd_ssid *ssid_probe; /* SSID selection based on ProbeReq */
  83. int vlan_id;
  84. struct ieee80211_ht_capabilities *ht_capabilities;
  85. #ifdef CONFIG_IEEE80211W
  86. int sa_query_count; /* number of pending SA Query requests;
  87. * 0 = no SA Query in progress */
  88. int sa_query_timed_out;
  89. u8 *sa_query_trans_id; /* buffer of WLAN_SA_QUERY_TR_ID_LEN *
  90. * sa_query_count octets of pending SA Query
  91. * transaction identifiers */
  92. struct os_time sa_query_start;
  93. #endif /* CONFIG_IEEE80211W */
  94. struct wpabuf *wps_ie; /* WPS IE from (Re)Association Request */
  95. struct wpabuf *p2p_ie; /* P2P IE from (Re)Association Request */
  96. };
  97. /* Default value for maximum station inactivity. After AP_MAX_INACTIVITY has
  98. * passed since last received frame from the station, a nullfunc data frame is
  99. * sent to the station. If this frame is not acknowledged and no other frames
  100. * have been received, the station will be disassociated after
  101. * AP_DISASSOC_DELAY seconds. Similarily, the station will be deauthenticated
  102. * after AP_DEAUTH_DELAY seconds has passed after disassociation. */
  103. #define AP_MAX_INACTIVITY (5 * 60)
  104. #define AP_DISASSOC_DELAY (1)
  105. #define AP_DEAUTH_DELAY (1)
  106. /* Number of seconds to keep STA entry with Authenticated flag after it has
  107. * been disassociated. */
  108. #define AP_MAX_INACTIVITY_AFTER_DISASSOC (1 * 30)
  109. /* Number of seconds to keep STA entry after it has been deauthenticated. */
  110. #define AP_MAX_INACTIVITY_AFTER_DEAUTH (1 * 5)
  111. struct hostapd_data;
  112. int ap_for_each_sta(struct hostapd_data *hapd,
  113. int (*cb)(struct hostapd_data *hapd, struct sta_info *sta,
  114. void *ctx),
  115. void *ctx);
  116. struct sta_info * ap_get_sta(struct hostapd_data *hapd, const u8 *sta);
  117. void ap_sta_hash_add(struct hostapd_data *hapd, struct sta_info *sta);
  118. void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta);
  119. void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta);
  120. void hostapd_free_stas(struct hostapd_data *hapd);
  121. void ap_handle_timer(void *eloop_ctx, void *timeout_ctx);
  122. void ap_sta_session_timeout(struct hostapd_data *hapd, struct sta_info *sta,
  123. u32 session_timeout);
  124. void ap_sta_no_session_timeout(struct hostapd_data *hapd,
  125. struct sta_info *sta);
  126. struct sta_info * ap_sta_add(struct hostapd_data *hapd, const u8 *addr);
  127. void ap_sta_disassociate(struct hostapd_data *hapd, struct sta_info *sta,
  128. u16 reason);
  129. void ap_sta_deauthenticate(struct hostapd_data *hapd, struct sta_info *sta,
  130. u16 reason);
  131. int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta,
  132. int old_vlanid);
  133. void ap_sta_start_sa_query(struct hostapd_data *hapd, struct sta_info *sta);
  134. void ap_sta_stop_sa_query(struct hostapd_data *hapd, struct sta_info *sta);
  135. int ap_check_sa_query_timeout(struct hostapd_data *hapd, struct sta_info *sta);
  136. void ap_sta_disconnect(struct hostapd_data *hapd, struct sta_info *sta,
  137. const u8 *addr, u16 reason);
  138. void ap_sta_set_authorized(struct hostapd_data *hapd,
  139. struct sta_info *sta, int authorized);
  140. static inline int ap_sta_is_authorized(struct sta_info *sta)
  141. {
  142. return sta->flags & WLAN_STA_AUTHORIZED;
  143. }
  144. void ap_sta_deauth_cb(struct hostapd_data *hapd, struct sta_info *sta);
  145. void ap_sta_disassoc_cb(struct hostapd_data *hapd, struct sta_info *sta);
  146. #endif /* STA_INFO_H */