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