Move STA entry structure into sta_info.h and remove ap.h
[wpasupplicant] / hostapd / driver.h
1 /*
2  * hostapd - driver interface definition
3  * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
4  * Copyright (c) 2007-2008, Intel Corporation
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * Alternatively, this software may be distributed under the terms of BSD
11  * license.
12  *
13  * See README and COPYING for more details.
14  */
15
16 #ifndef DRIVER_H
17 #define DRIVER_H
18
19 #include "sta_flags.h"
20
21 struct hostapd_data;
22
23 struct hostap_sta_driver_data {
24         unsigned long rx_packets, tx_packets, rx_bytes, tx_bytes;
25         unsigned long current_tx_rate;
26         unsigned long inactive_msec;
27         unsigned long flags;
28         unsigned long num_ps_buf_frames;
29         unsigned long tx_retry_failed;
30         unsigned long tx_retry_count;
31         int last_rssi;
32         int last_ack_rssi;
33 };
34
35 struct hostapd_sta_add_params {
36         const u8 *addr;
37         u16 aid;
38         u16 capability;
39         const u8 *supp_rates;
40         size_t supp_rates_len;
41         int flags;
42         u16 listen_interval;
43         const struct ht_cap_ie *ht_capabilities;
44 };
45
46 struct hostapd_freq_params {
47         int mode;
48         int freq;
49         int ht_enabled;
50         int sec_channel_offset; /* 0 = HT40 disabled, -1 = HT40 enabled,
51                                  * secondary channel below primary, 1 = HT40
52                                  * enabled, secondary channel above primary */
53 };
54
55 enum hostapd_driver_if_type {
56         HOSTAPD_IF_VLAN, HOSTAPD_IF_WDS
57 };
58
59 struct hostapd_neighbor_bss {
60         u8 bssid[ETH_ALEN];
61         int freq; /* MHz */
62         unsigned int ht:1;
63         int pri_chan;
64         int sec_chan; /* 0 for 20 MHz channels */
65 };
66
67 struct wpa_driver_ops {
68         const char *name;               /* as appears in the config file */
69
70         void * (*init)(struct hostapd_data *hapd);
71         void * (*init_bssid)(struct hostapd_data *hapd, const u8 *bssid);
72         void (*deinit)(void *priv);
73
74         int (*wireless_event_init)(void *priv);
75         void (*wireless_event_deinit)(void *priv);
76
77         /**
78          * set_8021x - enable/disable IEEE 802.1X support
79          * @ifname: Interface name (for multi-SSID/VLAN support)
80          * @priv: driver private data
81          * @enabled: 1 = enable, 0 = disable
82          *
83          * Returns: 0 on success, -1 on failure
84          *
85          * Configure the kernel driver to enable/disable 802.1X support.
86          * This may be an empty function if 802.1X support is always enabled.
87          */
88         int (*set_ieee8021x)(const char *ifname, void *priv, int enabled);
89
90         /**
91          * set_privacy - enable/disable privacy
92          * @priv: driver private data
93          * @enabled: 1 = privacy enabled, 0 = disabled
94          *
95          * Return: 0 on success, -1 on failure
96          *
97          * Configure privacy.
98          */
99         int (*set_privacy)(const char *ifname, void *priv, int enabled);
100
101         int (*set_encryption)(const char *ifname, void *priv, const char *alg,
102                               const u8 *addr, int idx,
103                               const u8 *key, size_t key_len, int txkey);
104         int (*get_seqnum)(const char *ifname, void *priv, const u8 *addr,
105                           int idx, u8 *seq);
106         int (*get_seqnum_igtk)(const char *ifname, void *priv, const u8 *addr,
107                                int idx, u8 *seq);
108         int (*flush)(void *priv);
109         int (*set_generic_elem)(const char *ifname, void *priv, const u8 *elem,
110                                 size_t elem_len);
111
112         int (*read_sta_data)(void *priv, struct hostap_sta_driver_data *data,
113                              const u8 *addr);
114         int (*send_eapol)(void *priv, const u8 *addr, const u8 *data,
115                           size_t data_len, int encrypt, const u8 *own_addr);
116         int (*sta_deauth)(void *priv, const u8 *addr, int reason);
117         int (*sta_disassoc)(void *priv, const u8 *addr, int reason);
118         int (*sta_remove)(void *priv, const u8 *addr);
119         int (*get_ssid)(const char *ifname, void *priv, u8 *buf, int len);
120         int (*set_ssid)(const char *ifname, void *priv, const u8 *buf,
121                         int len);
122         int (*set_countermeasures)(void *priv, int enabled);
123         int (*send_mgmt_frame)(void *priv, const void *msg, size_t len,
124                                int flags);
125         int (*set_assoc_ap)(void *priv, const u8 *addr);
126         /* note: sta_add() is deprecated; use sta_add2() instead */
127         int (*sta_add)(const char *ifname, void *priv, const u8 *addr, u16 aid,
128                        u16 capability, u8 *supp_rates, size_t supp_rates_len,
129                        int flags, u16 listen_interval);
130         int (*sta_add2)(const char *ifname, void *priv,
131                         struct hostapd_sta_add_params *params);
132         int (*get_inact_sec)(void *priv, const u8 *addr);
133         int (*sta_clear_stats)(void *priv, const u8 *addr);
134
135         /* note: set_freq() is deprecated; use set_freq2() instead */
136         int (*set_freq)(void *priv, int mode, int freq);
137         int (*set_freq2)(void *priv, struct hostapd_freq_params *freq);
138         int (*set_rts)(void *priv, int rts);
139         int (*get_rts)(void *priv, int *rts);
140         int (*set_frag)(void *priv, int frag);
141         int (*get_frag)(void *priv, int *frag);
142         int (*set_retry)(void *priv, int short_retry, int long_retry);
143         int (*get_retry)(void *priv, int *short_retry, int *long_retry);
144
145         int (*sta_set_flags)(void *priv, const u8 *addr,
146                              int total_flags, int flags_or, int flags_and);
147         int (*set_rate_sets)(void *priv, int *supp_rates, int *basic_rates,
148                              int mode);
149         int (*set_country)(void *priv, const char *country);
150         int (*set_ieee80211d)(void *priv, int enabled);
151         int (*set_beacon)(const char *ifname, void *priv,
152                           u8 *head, size_t head_len,
153                           u8 *tail, size_t tail_len);
154
155         /* Configure internal bridge:
156          * 0 = disabled, i.e., client separation is enabled (no bridging of
157          *     packets between associated STAs
158          * 1 = enabled, i.e., bridge packets between associated STAs (default)
159          */
160         int (*set_internal_bridge)(void *priv, int value);
161         int (*set_beacon_int)(void *priv, int value);
162         int (*set_dtim_period)(const char *ifname, void *priv, int value);
163         /* Configure broadcast SSID mode:
164          * 0 = include SSID in Beacon frames and reply to Probe Request frames
165          *     that use broadcast SSID
166          * 1 = hide SSID from Beacon frames and ignore Probe Request frames for
167          *     broadcast SSID
168          */
169         int (*set_broadcast_ssid)(void *priv, int value);
170         int (*set_cts_protect)(void *priv, int value);
171         int (*set_key_tx_rx_threshold)(void *priv, int value);
172         int (*set_preamble)(void *priv, int value);
173         int (*set_short_slot_time)(void *priv, int value);
174         int (*set_tx_queue_params)(void *priv, int queue, int aifs, int cw_min,
175                                    int cw_max, int burst_time);
176         int (*bss_add)(void *priv, const char *ifname, const u8 *bssid);
177         int (*bss_remove)(void *priv, const char *ifname);
178         int (*valid_bss_mask)(void *priv, const u8 *addr, const u8 *mask);
179         int (*passive_scan)(void *priv, int now, int our_mode_only,
180                             int interval, int _listen, int *channel,
181                             int *last_rx);
182         struct hostapd_hw_modes * (*get_hw_feature_data)(void *priv,
183                                                          u16 *num_modes,
184                                                          u16 *flags);
185         int (*if_add)(const char *iface, void *priv,
186                       enum hostapd_driver_if_type type, char *ifname,
187                       const u8 *addr);
188         int (*if_update)(void *priv, enum hostapd_driver_if_type type,
189                          char *ifname, const u8 *addr);
190         int (*if_remove)(void *priv, enum hostapd_driver_if_type type,
191                          const char *ifname, const u8 *addr);
192         int (*set_sta_vlan)(void *priv, const u8 *addr, const char *ifname,
193                             int vlan_id);
194         /**
195          * commit - Optional commit changes handler
196          * @priv: driver private data
197          * Returns: 0 on success, -1 on failure
198          *
199          * This optional handler function can be registered if the driver
200          * interface implementation needs to commit changes (e.g., by setting
201          * network interface up) at the end of initial configuration. If set,
202          * this handler will be called after initial setup has been completed.
203          */
204         int (*commit)(void *priv);
205
206         int (*send_ether)(void *priv, const u8 *dst, const u8 *src, u16 proto,
207                           const u8 *data, size_t data_len);
208
209         int (*set_radius_acl_auth)(void *priv, const u8 *mac, int accepted, 
210                                    u32 session_timeout);
211         int (*set_radius_acl_expire)(void *priv, const u8 *mac);
212
213         int (*set_ht_params)(const char *ifname, void *priv,
214                              const u8 *ht_capab, size_t ht_capab_len,
215                              const u8 *ht_oper, size_t ht_oper_len);
216
217         int (*set_wps_beacon_ie)(const char *ifname, void *priv,
218                                  const u8 *ie, size_t len);
219         int (*set_wps_probe_resp_ie)(const char *ifname, void *priv,
220                                      const u8 *ie, size_t len);
221
222         const struct hostapd_neighbor_bss *
223         (*get_neighbor_bss)(void *priv, size_t *num);
224 };
225
226 void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
227                            int reassoc);
228 void hostapd_tx_status(struct hostapd_data *hapd, const u8 *addr,
229                        const u8 *buf, size_t len, int ack);
230 void hostapd_rx_from_unknown_sta(struct hostapd_data *hapd, const u8 *addr);
231 int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
232                         const u8 *ie, size_t ielen);
233 void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr);
234 void hostapd_eapol_receive(struct hostapd_data *hapd, const u8 *sa,
235                            const u8 *buf, size_t len);
236
237 struct hostapd_frame_info {
238         u32 phytype;
239         u32 channel;
240         u32 datarate;
241         u32 ssi_signal;
242
243         unsigned int passive_scan:1;
244 };
245
246 void hostapd_mgmt_rx(struct hostapd_data *hapd, u8 *buf, size_t len,
247                      u16 stype, struct hostapd_frame_info *fi);
248 void hostapd_mgmt_tx_cb(struct hostapd_data *hapd, u8 *buf, size_t len,
249                         u16 stype, int ok);
250 void hostapd_michael_mic_failure(struct hostapd_data *hapd, const u8 *addr);
251
252 #endif /* DRIVER_H */