1 /*
2 * hostapd / Station table
3 * Copyright (c) 2002-2011, Jouni Malinen <j@w1.fi>
4 *
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
7 */
8
9 #ifndef STA_INFO_H
10 #define STA_INFO_H
11
12 /* STA flags */
13 #define WLAN_STA_AUTH BIT(0)
14 #define WLAN_STA_ASSOC BIT(1)
15 #define WLAN_STA_PS BIT(2)
16 #define WLAN_STA_TIM BIT(3)
17 #define WLAN_STA_PERM BIT(4)
18 #define WLAN_STA_AUTHORIZED BIT(5)
19 #define WLAN_STA_PENDING_POLL BIT(6) /* pending activity poll not ACKed */
20 #define WLAN_STA_SHORT_PREAMBLE BIT(7)
21 #define WLAN_STA_PREAUTH BIT(8)
22 #define WLAN_STA_WMM BIT(9)
23 #define WLAN_STA_MFP BIT(10)
24 #define WLAN_STA_HT BIT(11)
25 #define WLAN_STA_WPS BIT(12)
26 #define WLAN_STA_MAYBE_WPS BIT(13)
27 #define WLAN_STA_WDS BIT(14)
28 #define WLAN_STA_ASSOC_REQ_OK BIT(15)
29 #define WLAN_STA_WPS2 BIT(16)
30 #define WLAN_STA_GAS BIT(17)
31 #define WLAN_STA_VHT BIT(18)
32 #define WLAN_STA_PENDING_DISASSOC_CB BIT(29)
33 #define WLAN_STA_PENDING_DEAUTH_CB BIT(30)
34 #define WLAN_STA_NONERP BIT(31)
35
36 /* Maximum number of supported rates (from both Supported Rates and Extended
37 * Supported Rates IEs). */
38 #define WLAN_SUPP_RATES_MAX 32
39
40
41 struct sta_info {
42 struct sta_info *next; /* next entry in sta list */
43 struct sta_info *hnext; /* next entry in hash table list */
44 u8 addr[6];
45 u16 aid; /* STA's unique AID (1 .. 2007) or 0 if not yet assigned */
46 u32 flags; /* Bitfield of WLAN_STA_* */
47 u16 capability;
48 u16 listen_interval; /* or beacon_int for APs */
49 u8 supported_rates[WLAN_SUPP_RATES_MAX];
50 int supported_rates_len;
51
52 u16 auth_alg;
53
54 enum {
55 STA_NULLFUNC = 0, STA_DISASSOC, STA_DEAUTH, STA_REMOVE
56 } timeout_next;
57
58 struct wpa_state_machine *wpa_sm;
59
60 #ifdef CONFIG_IEEE80211W
61 int sa_query_count; /* number of pending SA Query requests;
62 * 0 = no SA Query in progress */
63 int sa_query_timed_out;
64 u8 *sa_query_trans_id; /* buffer of WLAN_SA_QUERY_TR_ID_LEN *
65 * sa_query_count octets of pending SA Query
66 * transaction identifiers */
67 struct os_time sa_query_start;
68 #endif /* CONFIG_IEEE80211W */
69
70 #ifdef CONFIG_INTERWORKING
71 #define GAS_DIALOG_MAX 8 /* Max concurrent dialog number */
72 struct gas_dialog_info *gas_dialog;
73 u8 gas_dialog_next;
74 #endif /* CONFIG_INTERWORKING */
75
76 #ifdef CONFIG_SAE
77 enum { SAE_INIT, SAE_COMMIT, SAE_CONFIRM } sae_state;
78 u16 sae_send_confirm;
79 #endif /* CONFIG_SAE */
80 };
81
82
83 /* Default value for maximum station inactivity. After AP_MAX_INACTIVITY has
84 * passed since last received frame from the station, a nullfunc data frame is
85 * sent to the station. If this frame is not acknowledged and no other frames
86 * have been received, the station will be disassociated after
87 * AP_DISASSOC_DELAY seconds. Similarly, the station will be deauthenticated
88 * after AP_DEAUTH_DELAY seconds has passed after disassociation. */
89 #define AP_MAX_INACTIVITY (5 * 60)
90 #define AP_DISASSOC_DELAY (1)
91 #define AP_DEAUTH_DELAY (1)
92 /* Number of seconds to keep STA entry with Authenticated flag after it has
93 * been disassociated. */
94 #define AP_MAX_INACTIVITY_AFTER_DISASSOC (1 * 30)
95 /* Number of seconds to keep STA entry after it has been deauthenticated. */
96 #define AP_MAX_INACTIVITY_AFTER_DEAUTH (1 * 5)
97
98
99 struct hostapd_data;
100
101 int ap_for_each_sta(struct hostapd_data *hapd,
102 int (*cb)(struct hostapd_data *hapd, struct sta_info *sta,
103 void *ctx),
104 void *ctx);
105 struct sta_info * ap_get_sta(struct hostapd_data *hapd, const u8 *sta);
106 void ap_sta_hash_add(struct hostapd_data *hapd, struct sta_info *sta);
107 void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta);
108 void hostapd_free_stas(struct hostapd_data *hapd);
109 void ap_handle_timer(void *eloop_ctx, void *timeout_ctx);
110 void ap_sta_session_timeout(struct hostapd_data *hapd, struct sta_info *sta,
111 u32 session_timeout);
112 void ap_sta_no_session_timeout(struct hostapd_data *hapd,
113 struct sta_info *sta);
114 struct sta_info * ap_sta_add(struct hostapd_data *hapd, const u8 *addr);
115 void ap_sta_disassociate(struct hostapd_data *hapd, struct sta_info *sta,
116 u16 reason);
117 void ap_sta_deauthenticate(struct hostapd_data *hapd, struct sta_info *sta,
118 u16 reason);
119 #ifdef CONFIG_WPS
120 int ap_sta_wps_cancel(struct hostapd_data *hapd,
121 struct sta_info *sta, void *ctx);
122 #endif /* CONFIG_WPS */
123 int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta,
124 int old_vlanid);
125 void ap_sta_start_sa_query(struct hostapd_data *hapd, struct sta_info *sta);
126 void ap_sta_stop_sa_query(struct hostapd_data *hapd, struct sta_info *sta);
127 int ap_check_sa_query_timeout(struct hostapd_data *hapd, struct sta_info *sta);
128 void ap_sta_disconnect(struct hostapd_data *hapd, struct sta_info *sta,
129 const u8 *addr, u16 reason);
130
131 void ap_sta_set_authorized(struct hostapd_data *hapd,
132 struct sta_info *sta, int authorized);
ap_sta_is_authorized(struct sta_info * sta)133 static inline int ap_sta_is_authorized(struct sta_info *sta)
134 {
135 return sta->flags & WLAN_STA_AUTHORIZED;
136 }
137
138 void ap_sta_deauth_cb(struct hostapd_data *hapd, struct sta_info *sta);
139 void ap_sta_disassoc_cb(struct hostapd_data *hapd, struct sta_info *sta);
140
141 #endif /* STA_INFO_H */
142