2 * hostapd - driver interface definition
3 * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
4 * Copyright (c) 2007-2008, Intel Corporation
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.
10 * Alternatively, this software may be distributed under the terms of BSD
13 * See README and COPYING for more details.
16 #ifndef HOSTAPD_DRIVER_H
17 #define HOSTAPD_DRIVER_H
20 #include "sta_flags.h"
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;
29 unsigned long num_ps_buf_frames;
30 unsigned long tx_retry_failed;
31 unsigned long tx_retry_count;
36 struct hostapd_sta_add_params {
41 size_t supp_rates_len;
44 const struct ht_cap_ie *ht_capabilities;
47 struct hostapd_freq_params {
52 int sec_channel_offset; /* 0 = HT40 disabled, -1 = HT40 enabled,
53 * secondary channel below primary, 1 = HT40
54 * enabled, secondary channel above primary */
57 enum hostapd_driver_if_type {
58 HOSTAPD_IF_VLAN, HOSTAPD_IF_WDS
61 struct hostapd_neighbor_bss {
66 int sec_chan; /* 0 for 20 MHz channels */
69 struct hapd_driver_ops {
70 const char *name; /* as appears in the config file */
72 void * (*init)(struct hostapd_data *hapd);
73 void * (*init_bssid)(struct hostapd_data *hapd, const u8 *bssid);
74 void (*deinit)(void *priv);
77 * set_8021x - enable/disable IEEE 802.1X support
78 * @ifname: Interface name (for multi-SSID/VLAN support)
79 * @priv: driver private data
80 * @enabled: 1 = enable, 0 = disable
82 * Returns: 0 on success, -1 on failure
84 * Configure the kernel driver to enable/disable 802.1X support.
85 * This may be an empty function if 802.1X support is always enabled.
87 int (*set_ieee8021x)(const char *ifname, void *priv, int enabled);
90 * set_privacy - enable/disable privacy
91 * @priv: driver private data
92 * @enabled: 1 = privacy enabled, 0 = disabled
94 * Return: 0 on success, -1 on failure
98 int (*set_privacy)(const char *ifname, void *priv, int enabled);
100 int (*set_key)(const char *ifname, void *priv, wpa_alg alg,
101 const u8 *addr, int key_idx, int set_tx, const u8 *seq,
102 size_t seq_len, const u8 *key, size_t key_len);
103 int (*get_seqnum)(const char *ifname, void *priv, const u8 *addr,
105 int (*get_seqnum_igtk)(const char *ifname, void *priv, const u8 *addr,
107 int (*flush)(void *priv);
108 int (*set_generic_elem)(const char *ifname, void *priv, const u8 *elem,
111 int (*read_sta_data)(void *priv, struct hostap_sta_driver_data *data,
113 int (*send_eapol)(void *priv, const u8 *addr, const u8 *data,
114 size_t data_len, int encrypt, const u8 *own_addr);
115 int (*sta_deauth)(void *priv, const u8 *addr, int reason);
116 int (*sta_disassoc)(void *priv, const u8 *addr, int reason);
117 int (*sta_remove)(void *priv, const u8 *addr);
118 int (*get_ssid)(const char *ifname, void *priv, u8 *buf, int len);
119 int (*set_ssid)(const char *ifname, void *priv, const u8 *buf,
121 int (*set_countermeasures)(void *priv, int enabled);
122 int (*send_mgmt_frame)(void *priv, const void *msg, size_t len,
124 int (*sta_add)(const char *ifname, void *priv,
125 struct hostapd_sta_add_params *params);
126 int (*get_inact_sec)(void *priv, const u8 *addr);
127 int (*sta_clear_stats)(void *priv, const u8 *addr);
129 int (*set_freq)(void *priv, struct hostapd_freq_params *freq);
130 int (*set_rts)(void *priv, int rts);
131 int (*set_frag)(void *priv, int frag);
132 int (*set_retry)(void *priv, int short_retry, int long_retry);
134 int (*sta_set_flags)(void *priv, const u8 *addr,
135 int total_flags, int flags_or, int flags_and);
136 int (*set_rate_sets)(void *priv, int *supp_rates, int *basic_rates,
138 int (*set_country)(void *priv, const char *country);
139 int (*set_ieee80211d)(void *priv, int enabled);
140 int (*set_beacon)(const char *ifname, void *priv,
141 const u8 *head, size_t head_len,
142 const u8 *tail, size_t tail_len, int dtim_period);
144 /* Configure internal bridge:
145 * 0 = disabled, i.e., client separation is enabled (no bridging of
146 * packets between associated STAs
147 * 1 = enabled, i.e., bridge packets between associated STAs (default)
149 int (*set_internal_bridge)(void *priv, int value);
150 int (*set_beacon_int)(void *priv, int value);
151 /* Configure broadcast SSID mode:
152 * 0 = include SSID in Beacon frames and reply to Probe Request frames
153 * that use broadcast SSID
154 * 1 = hide SSID from Beacon frames and ignore Probe Request frames for
157 int (*set_broadcast_ssid)(void *priv, int value);
158 int (*set_cts_protect)(void *priv, int value);
159 int (*set_preamble)(void *priv, int value);
160 int (*set_short_slot_time)(void *priv, int value);
161 int (*set_tx_queue_params)(void *priv, int queue, int aifs, int cw_min,
162 int cw_max, int burst_time);
163 int (*bss_add)(void *priv, const char *ifname, const u8 *bssid);
164 int (*bss_remove)(void *priv, const char *ifname);
165 int (*valid_bss_mask)(void *priv, const u8 *addr, const u8 *mask);
166 int (*passive_scan)(void *priv, int now, int our_mode_only,
167 int interval, int _listen, int *channel,
169 struct hostapd_hw_modes * (*get_hw_feature_data)(void *priv,
172 int (*if_add)(const char *iface, void *priv,
173 enum hostapd_driver_if_type type, char *ifname,
175 int (*if_update)(void *priv, enum hostapd_driver_if_type type,
176 char *ifname, const u8 *addr);
177 int (*if_remove)(void *priv, enum hostapd_driver_if_type type,
178 const char *ifname, const u8 *addr);
179 int (*set_sta_vlan)(void *priv, const u8 *addr, const char *ifname,
182 * commit - Optional commit changes handler
183 * @priv: driver private data
184 * Returns: 0 on success, -1 on failure
186 * This optional handler function can be registered if the driver
187 * interface implementation needs to commit changes (e.g., by setting
188 * network interface up) at the end of initial configuration. If set,
189 * this handler will be called after initial setup has been completed.
191 int (*commit)(void *priv);
193 int (*send_ether)(void *priv, const u8 *dst, const u8 *src, u16 proto,
194 const u8 *data, size_t data_len);
196 int (*set_radius_acl_auth)(void *priv, const u8 *mac, int accepted,
197 u32 session_timeout);
198 int (*set_radius_acl_expire)(void *priv, const u8 *mac);
200 int (*set_ht_params)(const char *ifname, void *priv,
201 const u8 *ht_capab, size_t ht_capab_len,
202 const u8 *ht_oper, size_t ht_oper_len);
204 int (*set_wps_beacon_ie)(const char *ifname, void *priv,
205 const u8 *ie, size_t len);
206 int (*set_wps_probe_resp_ie)(const char *ifname, void *priv,
207 const u8 *ie, size_t len);
209 const struct hostapd_neighbor_bss *
210 (*get_neighbor_bss)(void *priv, size_t *num);
215 void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
217 void hostapd_tx_status(struct hostapd_data *hapd, const u8 *addr,
218 const u8 *buf, size_t len, int ack);
219 void hostapd_rx_from_unknown_sta(struct hostapd_data *hapd, const u8 *addr);
220 int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
221 const u8 *ie, size_t ielen);
222 void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr);
223 void hostapd_eapol_receive(struct hostapd_data *hapd, const u8 *sa,
224 const u8 *buf, size_t len);
226 struct hostapd_frame_info {
232 unsigned int passive_scan:1;
235 void hostapd_mgmt_rx(struct hostapd_data *hapd, u8 *buf, size_t len,
236 u16 stype, struct hostapd_frame_info *fi);
237 void hostapd_mgmt_tx_cb(struct hostapd_data *hapd, u8 *buf, size_t len,
239 void hostapd_michael_mic_failure(struct hostapd_data *hapd, const u8 *addr);
240 struct hostapd_data * hostapd_sta_get_bss(struct hostapd_data *hapd,
243 #endif /* HOSTAPD_DRIVER_H */