Include sta_flags.h explicitly, not via sta_info.h
[libeap.git] / hostapd / sta_info.h
1 /*
2  * hostapd / Station table
3  * Copyright (c) 2002-2008, 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
15 #ifndef STA_INFO_H
16 #define STA_INFO_H
17
18 #ifdef CONFIG_IEEE80211N
19 #include "common/ieee802_11_defs.h"
20 #endif /* CONFIG_IEEE80211N */
21
22 /* Maximum number of supported rates (from both Supported Rates and Extended
23  * Supported Rates IEs). */
24 #define WLAN_SUPP_RATES_MAX 32
25
26
27 struct sta_info {
28         struct sta_info *next; /* next entry in sta list */
29         struct sta_info *hnext; /* next entry in hash table list */
30         u8 addr[6];
31         u16 aid; /* STA's unique AID (1 .. 2007) or 0 if not yet assigned */
32         u32 flags;
33         u16 capability;
34         u16 listen_interval; /* or beacon_int for APs */
35         u8 supported_rates[WLAN_SUPP_RATES_MAX];
36         int supported_rates_len;
37
38         unsigned int nonerp_set:1;
39         unsigned int no_short_slot_time_set:1;
40         unsigned int no_short_preamble_set:1;
41         unsigned int no_ht_gf_set:1;
42         unsigned int no_ht_set:1;
43         unsigned int ht_20mhz_set:1;
44
45         u16 auth_alg;
46         u8 previous_ap[6];
47
48         enum {
49                 STA_NULLFUNC = 0, STA_DISASSOC, STA_DEAUTH, STA_REMOVE
50         } timeout_next;
51
52         /* IEEE 802.1X related data */
53         struct eapol_state_machine *eapol_sm;
54
55         /* IEEE 802.11f (IAPP) related data */
56         struct ieee80211_mgmt *last_assoc_req;
57
58         u32 acct_session_id_hi;
59         u32 acct_session_id_lo;
60         time_t acct_session_start;
61         int acct_session_started;
62         int acct_terminate_cause; /* Acct-Terminate-Cause */
63         int acct_interim_interval; /* Acct-Interim-Interval */
64
65         unsigned long last_rx_bytes;
66         unsigned long last_tx_bytes;
67         u32 acct_input_gigawords; /* Acct-Input-Gigawords */
68         u32 acct_output_gigawords; /* Acct-Output-Gigawords */
69
70         u8 *challenge; /* IEEE 802.11 Shared Key Authentication Challenge */
71
72         struct wpa_state_machine *wpa_sm;
73         struct rsn_preauth_interface *preauth_iface;
74
75         struct hostapd_ssid *ssid; /* SSID selection based on (Re)AssocReq */
76         struct hostapd_ssid *ssid_probe; /* SSID selection based on ProbeReq */
77
78         int vlan_id;
79
80 #ifdef CONFIG_IEEE80211N
81         struct ieee80211_ht_capabilities ht_capabilities;
82 #endif /* CONFIG_IEEE80211N */
83
84 #ifdef CONFIG_IEEE80211W
85         int sa_query_count; /* number of pending SA Query requests;
86                              * 0 = no SA Query in progress */
87         int sa_query_timed_out;
88         u8 *sa_query_trans_id; /* buffer of WLAN_SA_QUERY_TR_ID_LEN *
89                                 * sa_query_count octets of pending SA Query
90                                 * transaction identifiers */
91         struct os_time sa_query_start;
92 #endif /* CONFIG_IEEE80211W */
93
94         struct wpabuf *wps_ie; /* WPS IE from (Re)Association Request */
95 };
96
97
98 /* Default value for maximum station inactivity. After AP_MAX_INACTIVITY has
99  * passed since last received frame from the station, a nullfunc data frame is
100  * sent to the station. If this frame is not acknowledged and no other frames
101  * have been received, the station will be disassociated after
102  * AP_DISASSOC_DELAY seconds. Similarily, the station will be deauthenticated
103  * after AP_DEAUTH_DELAY seconds has passed after disassociation. */
104 #define AP_MAX_INACTIVITY (5 * 60)
105 #define AP_DISASSOC_DELAY (1)
106 #define AP_DEAUTH_DELAY (1)
107 /* Number of seconds to keep STA entry with Authenticated flag after it has
108  * been disassociated. */
109 #define AP_MAX_INACTIVITY_AFTER_DISASSOC (1 * 30)
110 /* Number of seconds to keep STA entry after it has been deauthenticated. */
111 #define AP_MAX_INACTIVITY_AFTER_DEAUTH (1 * 5)
112
113
114 struct hostapd_data;
115
116 int ap_for_each_sta(struct hostapd_data *hapd,
117                     int (*cb)(struct hostapd_data *hapd, struct sta_info *sta,
118                               void *ctx),
119                     void *ctx);
120 struct sta_info * ap_get_sta(struct hostapd_data *hapd, const u8 *sta);
121 void ap_sta_hash_add(struct hostapd_data *hapd, struct sta_info *sta);
122 void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta);
123 void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta);
124 void hostapd_free_stas(struct hostapd_data *hapd);
125 void ap_handle_timer(void *eloop_ctx, void *timeout_ctx);
126 void ap_sta_session_timeout(struct hostapd_data *hapd, struct sta_info *sta,
127                             u32 session_timeout);
128 void ap_sta_no_session_timeout(struct hostapd_data *hapd,
129                                struct sta_info *sta);
130 struct sta_info * ap_sta_add(struct hostapd_data *hapd, const u8 *addr);
131 void ap_sta_disassociate(struct hostapd_data *hapd, struct sta_info *sta,
132                          u16 reason);
133 void ap_sta_deauthenticate(struct hostapd_data *hapd, struct sta_info *sta,
134                            u16 reason);
135 int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta,
136                      int old_vlanid);
137 void ap_sta_start_sa_query(struct hostapd_data *hapd, struct sta_info *sta);
138 void ap_sta_stop_sa_query(struct hostapd_data *hapd, struct sta_info *sta);
139 int ap_check_sa_query_timeout(struct hostapd_data *hapd, struct sta_info *sta);
140
141 #endif /* STA_INFO_H */