2 * hostapd - internal driver interface wrappers
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.
19 #include "drivers/driver.h"
23 hostapd_driver_init(struct hostapd_data *hapd)
25 if (hapd->driver == NULL || hapd->driver->hapd_init == NULL)
27 return hapd->driver->hapd_init(hapd);
31 hostapd_driver_init_bssid(struct hostapd_data *hapd, const u8 *bssid)
33 if (hapd->driver == NULL || hapd->driver->init_bssid == NULL)
35 return hapd->driver->init_bssid(hapd, bssid);
39 hostapd_driver_deinit(struct hostapd_data *hapd)
41 if (hapd->driver == NULL || hapd->driver->hapd_deinit == NULL)
43 hapd->driver->hapd_deinit(hapd->drv_priv);
47 hostapd_set_ieee8021x(const char *ifname, struct hostapd_data *hapd,
50 if (hapd->driver == NULL || hapd->driver->set_ieee8021x == NULL)
52 return hapd->driver->set_ieee8021x(ifname, hapd->drv_priv, enabled);
56 hostapd_set_privacy(struct hostapd_data *hapd, int enabled)
58 if (hapd->driver == NULL || hapd->driver->set_privacy == NULL)
60 return hapd->driver->set_privacy(hapd->conf->iface, hapd->drv_priv,
65 hostapd_set_key(const char *ifname, struct hostapd_data *hapd,
66 wpa_alg alg, const u8 *addr, int key_idx,
67 int set_tx, const u8 *seq, size_t seq_len,
68 const u8 *key, size_t key_len)
70 if (hapd->driver == NULL || hapd->driver->hapd_set_key == NULL)
72 return hapd->driver->hapd_set_key(ifname, hapd->drv_priv, alg, addr,
73 key_idx, set_tx, seq, seq_len, key,
78 hostapd_get_seqnum(const char *ifname, struct hostapd_data *hapd,
79 const u8 *addr, int idx, u8 *seq)
81 if (hapd->driver == NULL || hapd->driver->get_seqnum == NULL)
83 return hapd->driver->get_seqnum(ifname, hapd->drv_priv, addr, idx,
88 hostapd_get_seqnum_igtk(const char *ifname, struct hostapd_data *hapd,
89 const u8 *addr, int idx, u8 *seq)
91 if (hapd->driver == NULL || hapd->driver->get_seqnum_igtk == NULL)
93 return hapd->driver->get_seqnum_igtk(ifname, hapd->drv_priv, addr, idx,
98 hostapd_flush(struct hostapd_data *hapd)
100 if (hapd->driver == NULL || hapd->driver->flush == NULL)
102 return hapd->driver->flush(hapd->drv_priv);
106 hostapd_set_generic_elem(struct hostapd_data *hapd, const u8 *elem,
109 if (hapd->driver == NULL || hapd->driver->set_generic_elem == NULL)
111 return hapd->driver->set_generic_elem(hapd->conf->iface,
112 hapd->drv_priv, elem, elem_len);
116 hostapd_read_sta_data(struct hostapd_data *hapd,
117 struct hostap_sta_driver_data *data, const u8 *addr)
119 if (hapd->driver == NULL || hapd->driver->read_sta_data == NULL)
121 return hapd->driver->read_sta_data(hapd->drv_priv, data, addr);
125 hostapd_send_eapol(struct hostapd_data *hapd, const u8 *addr, const u8 *data,
126 size_t data_len, int encrypt)
128 if (hapd->driver == NULL || hapd->driver->hapd_send_eapol == NULL)
130 return hapd->driver->hapd_send_eapol(hapd->drv_priv, addr, data,
136 hostapd_sta_deauth(struct hostapd_data *hapd, const u8 *addr, int reason)
138 if (hapd->driver == NULL || hapd->driver->sta_deauth == NULL)
140 return hapd->driver->sta_deauth(hapd->drv_priv, addr, reason);
144 hostapd_sta_disassoc(struct hostapd_data *hapd, const u8 *addr, int reason)
146 if (hapd->driver == NULL || hapd->driver->sta_disassoc == NULL)
148 return hapd->driver->sta_disassoc(hapd->drv_priv, addr, reason);
152 hostapd_sta_remove(struct hostapd_data *hapd, const u8 *addr)
154 if (hapd->driver == NULL || hapd->driver->sta_remove == NULL)
156 return hapd->driver->sta_remove(hapd->drv_priv, addr);
160 hostapd_get_ssid(struct hostapd_data *hapd, u8 *buf, size_t len)
162 if (hapd->driver == NULL || hapd->driver->hapd_get_ssid == NULL)
164 return hapd->driver->hapd_get_ssid(hapd->conf->iface, hapd->drv_priv,
169 hostapd_set_ssid(struct hostapd_data *hapd, const u8 *buf, size_t len)
171 if (hapd->driver == NULL || hapd->driver->hapd_set_ssid == NULL)
173 return hapd->driver->hapd_set_ssid(hapd->conf->iface, hapd->drv_priv,
178 hostapd_send_mgmt_frame(struct hostapd_data *hapd, const void *msg, size_t len)
180 if (hapd->driver == NULL || hapd->driver->send_mlme == NULL)
182 return hapd->driver->send_mlme(hapd->drv_priv, msg, len);
186 hostapd_set_countermeasures(struct hostapd_data *hapd, int enabled)
188 if (hapd->driver == NULL ||
189 hapd->driver->hapd_set_countermeasures == NULL)
191 return hapd->driver->hapd_set_countermeasures(hapd->drv_priv, enabled);
195 hostapd_sta_add(const char *ifname, struct hostapd_data *hapd, const u8 *addr,
196 u16 aid, u16 capability, const u8 *supp_rates,
197 size_t supp_rates_len, int flags, u16 listen_interval,
198 const struct ht_cap_ie *ht_capabilities)
200 struct hostapd_sta_add_params params;
202 if (hapd->driver == NULL)
204 if (hapd->driver->sta_add == NULL)
207 os_memset(¶ms, 0, sizeof(params));
210 params.capability = capability;
211 params.supp_rates = supp_rates;
212 params.supp_rates_len = supp_rates_len;
213 params.flags = flags;
214 params.listen_interval = listen_interval;
215 params.ht_capabilities = ht_capabilities;
216 return hapd->driver->sta_add(ifname, hapd->drv_priv, ¶ms);
220 hostapd_get_inact_sec(struct hostapd_data *hapd, const u8 *addr)
222 if (hapd->driver == NULL || hapd->driver->get_inact_sec == NULL)
224 return hapd->driver->get_inact_sec(hapd->drv_priv, addr);
228 hostapd_set_freq(struct hostapd_data *hapd, int mode, int freq, int channel,
229 int ht_enabled, int sec_channel_offset)
231 struct hostapd_freq_params data;
232 if (hapd->driver == NULL)
234 if (hapd->driver->set_freq == NULL)
236 os_memset(&data, 0, sizeof(data));
239 data.channel = channel;
240 data.ht_enabled = ht_enabled;
241 data.sec_channel_offset = sec_channel_offset;
242 return hapd->driver->set_freq(hapd->drv_priv, &data);
246 hostapd_set_rts(struct hostapd_data *hapd, int rts)
248 if (hapd->driver == NULL || hapd->driver->set_rts == NULL)
250 return hapd->driver->set_rts(hapd->drv_priv, rts);
254 hostapd_set_frag(struct hostapd_data *hapd, int frag)
256 if (hapd->driver == NULL || hapd->driver->set_frag == NULL)
258 return hapd->driver->set_frag(hapd->drv_priv, frag);
262 hostapd_set_retry(struct hostapd_data *hapd, int short_retry, int long_retry)
264 if (hapd->driver == NULL || hapd->driver->set_retry == NULL)
266 return hapd->driver->set_retry(hapd->drv_priv, short_retry,
271 hostapd_sta_set_flags(struct hostapd_data *hapd, u8 *addr,
272 int total_flags, int flags_or, int flags_and)
274 if (hapd->driver == NULL || hapd->driver->sta_set_flags == NULL)
276 return hapd->driver->sta_set_flags(hapd->drv_priv, addr, total_flags,
277 flags_or, flags_and);
281 hostapd_set_rate_sets(struct hostapd_data *hapd, int *supp_rates,
282 int *basic_rates, int mode)
284 if (hapd->driver == NULL || hapd->driver->set_rate_sets == NULL)
286 return hapd->driver->set_rate_sets(hapd->drv_priv, supp_rates,
291 hostapd_set_country(struct hostapd_data *hapd, const char *country)
293 if (hapd->driver == NULL ||
294 hapd->driver->hapd_set_country == NULL)
296 return hapd->driver->hapd_set_country(hapd->drv_priv, country);
300 hostapd_set_ieee80211d(struct hostapd_data *hapd, int enabled)
302 if (hapd->driver == NULL ||
303 hapd->driver->set_ieee80211d == NULL)
305 return hapd->driver->set_ieee80211d(hapd->drv_priv, enabled);
309 hostapd_sta_clear_stats(struct hostapd_data *hapd, const u8 *addr)
311 if (hapd->driver == NULL || hapd->driver->sta_clear_stats == NULL)
313 return hapd->driver->sta_clear_stats(hapd->drv_priv, addr);
317 hostapd_set_beacon(const char *ifname, struct hostapd_data *hapd,
318 const u8 *head, size_t head_len,
319 const u8 *tail, size_t tail_len, int dtim_period)
321 if (hapd->driver == NULL || hapd->driver->hapd_set_beacon == NULL)
323 return hapd->driver->hapd_set_beacon(ifname, hapd->drv_priv,
325 tail, tail_len, dtim_period);
329 hostapd_set_internal_bridge(struct hostapd_data *hapd, int value)
331 if (hapd->driver == NULL || hapd->driver->set_internal_bridge == NULL)
333 return hapd->driver->set_internal_bridge(hapd->drv_priv, value);
337 hostapd_set_beacon_int(struct hostapd_data *hapd, int value)
339 if (hapd->driver == NULL || hapd->driver->hapd_set_beacon_int == NULL)
341 return hapd->driver->hapd_set_beacon_int(hapd->drv_priv, value);
345 hostapd_set_broadcast_ssid(struct hostapd_data *hapd, int value)
347 if (hapd->driver == NULL || hapd->driver->set_broadcast_ssid == NULL)
349 return hapd->driver->set_broadcast_ssid(hapd->drv_priv, value);
353 hostapd_set_cts_protect(struct hostapd_data *hapd, int value)
355 if (hapd->driver == NULL || hapd->driver->set_cts_protect == NULL)
357 return hapd->driver->set_cts_protect(hapd->drv_priv, value);
361 hostapd_set_preamble(struct hostapd_data *hapd, int value)
363 if (hapd->driver == NULL || hapd->driver->set_preamble == NULL)
365 return hapd->driver->set_preamble(hapd->drv_priv, value);
369 hostapd_set_short_slot_time(struct hostapd_data *hapd, int value)
371 if (hapd->driver == NULL || hapd->driver->set_short_slot_time == NULL)
373 return hapd->driver->set_short_slot_time(hapd->drv_priv, value);
377 hostapd_set_tx_queue_params(struct hostapd_data *hapd, int queue, int aifs,
378 int cw_min, int cw_max, int burst_time)
380 if (hapd->driver == NULL || hapd->driver->set_tx_queue_params == NULL)
382 return hapd->driver->set_tx_queue_params(hapd->drv_priv, queue, aifs,
383 cw_min, cw_max, burst_time);
387 hostapd_bss_add(struct hostapd_data *hapd, const char *ifname, const u8 *bssid)
389 if (hapd->driver == NULL || hapd->driver->bss_add == NULL)
391 return hapd->driver->bss_add(hapd->drv_priv, ifname, bssid);
395 hostapd_bss_remove(struct hostapd_data *hapd, const char *ifname)
397 if (hapd->driver == NULL || hapd->driver->bss_remove == NULL)
399 return hapd->driver->bss_remove(hapd->drv_priv, ifname);
403 hostapd_valid_bss_mask(struct hostapd_data *hapd, const u8 *addr,
406 if (hapd->driver == NULL || hapd->driver->valid_bss_mask == NULL)
408 return hapd->driver->valid_bss_mask(hapd->drv_priv, addr, mask);
412 hostapd_if_add(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
413 char *ifname, const u8 *addr)
415 if (hapd->driver == NULL || hapd->driver->if_add == NULL)
417 return hapd->driver->if_add(hapd->conf->iface, hapd->drv_priv, type,
422 hostapd_if_update(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
423 char *ifname, const u8 *addr)
425 if (hapd->driver == NULL || hapd->driver->if_update == NULL)
427 return hapd->driver->if_update(hapd->drv_priv, type, ifname, addr);
431 hostapd_if_remove(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
432 char *ifname, const u8 *addr)
434 if (hapd->driver == NULL || hapd->driver->if_remove == NULL)
436 return hapd->driver->if_remove(hapd->drv_priv, type, ifname, addr);
440 hostapd_passive_scan(struct hostapd_data *hapd, int now, int our_mode_only,
441 int interval, int _listen, int *channel,
444 if (hapd->driver == NULL || hapd->driver->passive_scan == NULL)
446 return hapd->driver->passive_scan(hapd->drv_priv, now, our_mode_only,
447 interval, _listen, channel, last_rx);
450 static inline struct hostapd_hw_modes *
451 hostapd_get_hw_feature_data(struct hostapd_data *hapd, u16 *num_modes,
454 if (hapd->driver == NULL ||
455 hapd->driver->get_hw_feature_data == NULL)
457 return hapd->driver->get_hw_feature_data(hapd->drv_priv, num_modes,
462 hostapd_set_sta_vlan(const char *ifname, struct hostapd_data *hapd,
463 const u8 *addr, int vlan_id)
465 if (hapd->driver == NULL || hapd->driver->set_sta_vlan == NULL)
467 return hapd->driver->set_sta_vlan(hapd->drv_priv, addr, ifname, vlan_id);
471 hostapd_driver_commit(struct hostapd_data *hapd)
473 if (hapd->driver == NULL || hapd->driver->commit == NULL)
475 return hapd->driver->commit(hapd->drv_priv);
479 hostapd_set_radius_acl_auth(struct hostapd_data *hapd, const u8 *mac,
480 int accepted, u32 session_timeout)
482 if (hapd->driver == NULL || hapd->driver->set_radius_acl_auth == NULL)
484 return hapd->driver->set_radius_acl_auth(hapd->drv_priv, mac, accepted,
489 hostapd_set_radius_acl_expire(struct hostapd_data *hapd, const u8 *mac)
491 if (hapd->driver == NULL ||
492 hapd->driver->set_radius_acl_expire == NULL)
494 return hapd->driver->set_radius_acl_expire(hapd->drv_priv, mac);
497 #ifdef CONFIG_IEEE80211N
499 hostapd_set_ht_params(const char *ifname, struct hostapd_data *hapd,
500 const u8 *ht_capab, size_t ht_capab_len,
501 const u8 *ht_oper, size_t ht_oper_len)
503 if (hapd->driver == NULL || hapd->driver->set_ht_params == NULL ||
504 ht_capab == NULL || ht_oper == NULL)
506 return hapd->driver->set_ht_params(
507 ifname, hapd->drv_priv, ht_capab, ht_capab_len,
508 ht_oper, ht_oper_len);
510 #endif /* CONFIG_IEEE80211N */
513 hostapd_drv_none(struct hostapd_data *hapd)
515 return hapd->driver && os_strcmp(hapd->driver->name, "none") == 0;
519 hostapd_set_wps_beacon_ie(struct hostapd_data *hapd, const u8 *ie, size_t len)
521 if (hapd->driver == NULL || hapd->driver->set_wps_beacon_ie == NULL)
523 return hapd->driver->set_wps_beacon_ie(hapd->conf->iface,
524 hapd->drv_priv, ie, len);
528 hostapd_set_wps_probe_resp_ie(struct hostapd_data *hapd, const u8 *ie,
531 if (hapd->driver == NULL ||
532 hapd->driver->set_wps_probe_resp_ie == NULL)
534 return hapd->driver->set_wps_probe_resp_ie(hapd->conf->iface,
535 hapd->drv_priv, ie, len);
538 static inline const struct hostapd_neighbor_bss *
539 hostapd_driver_get_neighbor_bss(struct hostapd_data *hapd, size_t *num)
541 if (hapd->driver == NULL || hapd->driver->get_neighbor_bss == NULL)
543 return hapd->driver->get_neighbor_bss(hapd->drv_priv, num);
546 #endif /* DRIVER_I_H */