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