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