1 /*
2 * hostapd / Station table
3 * Copyright (c) 2002-2017, 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 u32 flags; /* Bitfield of WLAN_STA_* */
46
47 /* IEEE 802.1X related data */
48 struct eapol_state_machine *eapol_sm;
49 struct wpa_state_machine *wpa_sm;
50
51 char *identity; /* User-Name from RADIUS */
52
53 u16 auth_alg;
54 #ifdef CONFIG_INTERWORKING
55 #define GAS_DIALOG_MAX 8 /* Max concurrent dialog number */
56 struct gas_dialog_info *gas_dialog;
57 u8 gas_dialog_next;
58 #endif /* CONFIG_INTERWORKING */
59 struct wpabuf *wps_ie; /* WPS IE from (Re)Association Request */
60
61 #ifdef ESP_SUPPLICANT
62 #ifdef CONFIG_SAE
63 void *lock;
64 struct sae_data *sae;
65 bool sae_commit_processing; /* halt queuing commit while we are
66 * processing commit for that station */
67 bool remove_pending; /* Flag to indicate to free station when
68 * whose mutex is taken by task */
69 #endif /* CONFIG_SAE */
70 #endif /* ESP_SUPPLICANT */
71
72 };
73
74
75 /* Default value for maximum station inactivity. After AP_MAX_INACTIVITY has
76 * passed since last received frame from the station, a nullfunc data frame is
77 * sent to the station. If this frame is not acknowledged and no other frames
78 * have been received, the station will be disassociated after
79 * AP_DISASSOC_DELAY seconds. Similarly, the station will be deauthenticated
80 * after AP_DEAUTH_DELAY seconds has passed after disassociation. */
81 #define AP_MAX_INACTIVITY (5 * 60)
82 #define AP_DISASSOC_DELAY (1)
83 #define AP_DEAUTH_DELAY (1)
84 /* Number of seconds to keep STA entry with Authenticated flag after it has
85 * been disassociated. */
86 #define AP_MAX_INACTIVITY_AFTER_DISASSOC (1 * 30)
87 /* Number of seconds to keep STA entry after it has been deauthenticated. */
88 #define AP_MAX_INACTIVITY_AFTER_DEAUTH (1 * 5)
89
90
91 struct hostapd_data;
92
93 int ap_for_each_sta(struct hostapd_data *hapd,
94 int (*cb)(struct hostapd_data *hapd, struct sta_info *sta,
95 void *ctx),
96 void *ctx);
97 struct sta_info * ap_get_sta(struct hostapd_data *hapd, const u8 *sta);
98 void ap_sta_hash_add(struct hostapd_data *hapd, struct sta_info *sta);
99 void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta);
100 void hostapd_free_stas(struct hostapd_data *hapd);
101 void ap_handle_timer(void *eloop_ctx, void *timeout_ctx);
102 void ap_sta_session_timeout(struct hostapd_data *hapd, struct sta_info *sta,
103 u32 session_timeout);
104 void ap_sta_no_session_timeout(struct hostapd_data *hapd,
105 struct sta_info *sta);
106 struct sta_info * ap_sta_add(struct hostapd_data *hapd, const u8 *addr);
107 void ap_sta_disassociate(struct hostapd_data *hapd, struct sta_info *sta,
108 u16 reason);
109 void ap_sta_deauthenticate(struct hostapd_data *hapd, struct sta_info *sta,
110 u16 reason);
111 #ifdef CONFIG_WPS
112 int ap_sta_wps_cancel(struct hostapd_data *hapd,
113 struct sta_info *sta, void *ctx);
114 #endif /* CONFIG_WPS */
115 int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta,
116 int old_vlanid);
117 void ap_sta_start_sa_query(struct hostapd_data *hapd, struct sta_info *sta);
118 void ap_sta_stop_sa_query(struct hostapd_data *hapd, struct sta_info *sta);
119 int ap_check_sa_query_timeout(struct hostapd_data *hapd, struct sta_info *sta);
120 void ap_sta_disconnect(struct hostapd_data *hapd, struct sta_info *sta,
121 const u8 *addr, u16 reason);
122
123 void ap_sta_set_authorized(struct hostapd_data *hapd,
124 struct sta_info *sta, int authorized);
ap_sta_is_authorized(struct sta_info * sta)125 static inline int ap_sta_is_authorized(struct sta_info *sta)
126 {
127 return sta->flags & WLAN_STA_AUTHORIZED;
128 }
129
130 void ap_sta_deauth_cb(struct hostapd_data *hapd, struct sta_info *sta);
131 void ap_sta_disassoc_cb(struct hostapd_data *hapd, struct sta_info *sta);
132 void ap_sta_clear_disconnect_timeouts(struct hostapd_data *hapd,
133 struct sta_info *sta);
134
135 int ap_sta_flags_txt(u32 flags, char *buf, size_t buflen);
136 void ap_sta_delayed_1x_auth_fail_disconnect(struct hostapd_data *hapd,
137 struct sta_info *sta);
138 int ap_sta_pending_delayed_1x_auth_fail_disconnect(struct hostapd_data *hapd,
139 struct sta_info *sta);
140 int ap_sta_re_add(struct hostapd_data *hapd, struct sta_info *sta);
141
142 void ap_free_sta_pasn(struct hostapd_data *hapd, struct sta_info *sta);
143
144 #endif /* STA_INFO_H */
145