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.
23 hostapd_driver_init(struct hostapd_data *hapd)
25 if (hapd->driver == NULL || hapd->driver->init == NULL)
27 return hapd->driver->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->deinit == NULL)
43 hapd->driver->deinit(hapd->drv_priv);
47 hostapd_wireless_event_init(struct hostapd_data *hapd)
49 if (hapd->driver == NULL ||
50 hapd->driver->wireless_event_init == NULL)
52 return hapd->driver->wireless_event_init(hapd->drv_priv);
56 hostapd_wireless_event_deinit(struct hostapd_data *hapd)
58 if (hapd->driver == NULL ||
59 hapd->driver->wireless_event_deinit == NULL)
61 hapd->driver->wireless_event_deinit(hapd->drv_priv);
65 hostapd_set_ieee8021x(const char *ifname, struct hostapd_data *hapd,
68 if (hapd->driver == NULL || hapd->driver->set_ieee8021x == NULL)
70 return hapd->driver->set_ieee8021x(ifname, hapd->drv_priv, enabled);
74 hostapd_set_privacy(struct hostapd_data *hapd, int enabled)
76 if (hapd->driver == NULL || hapd->driver->set_privacy == NULL)
78 return hapd->driver->set_privacy(hapd->conf->iface, hapd->drv_priv,
83 hostapd_set_encryption(const char *ifname, struct hostapd_data *hapd,
84 const char *alg, const u8 *addr, int idx,
85 u8 *key, size_t key_len, int txkey)
87 if (hapd->driver == NULL || hapd->driver->set_encryption == NULL)
89 return hapd->driver->set_encryption(ifname, hapd->drv_priv, alg, addr,
90 idx, key, key_len, txkey);
94 hostapd_get_seqnum(const char *ifname, struct hostapd_data *hapd,
95 const u8 *addr, int idx, u8 *seq)
97 if (hapd->driver == NULL || hapd->driver->get_seqnum == NULL)
99 return hapd->driver->get_seqnum(ifname, hapd->drv_priv, addr, idx,
104 hostapd_get_seqnum_igtk(const char *ifname, struct hostapd_data *hapd,
105 const u8 *addr, int idx, u8 *seq)
107 if (hapd->driver == NULL || hapd->driver->get_seqnum_igtk == NULL)
109 return hapd->driver->get_seqnum_igtk(ifname, hapd->drv_priv, addr, idx,
114 hostapd_flush(struct hostapd_data *hapd)
116 if (hapd->driver == NULL || hapd->driver->flush == NULL)
118 return hapd->driver->flush(hapd->drv_priv);
122 hostapd_set_generic_elem(struct hostapd_data *hapd, const u8 *elem,
125 if (hapd->driver == NULL || hapd->driver->set_generic_elem == NULL)
127 return hapd->driver->set_generic_elem(hapd->conf->iface,
128 hapd->drv_priv, elem, elem_len);
132 hostapd_read_sta_data(struct hostapd_data *hapd,
133 struct hostap_sta_driver_data *data, const u8 *addr)
135 if (hapd->driver == NULL || hapd->driver->read_sta_data == NULL)
137 return hapd->driver->read_sta_data(hapd->drv_priv, data, addr);
141 hostapd_send_eapol(struct hostapd_data *hapd, const u8 *addr, const u8 *data,
142 size_t data_len, int encrypt)
144 if (hapd->driver == NULL || hapd->driver->send_eapol == NULL)
146 return hapd->driver->send_eapol(hapd->drv_priv, addr, data, data_len,
147 encrypt, hapd->own_addr);
151 hostapd_sta_deauth(struct hostapd_data *hapd, const u8 *addr, int reason)
153 if (hapd->driver == NULL || hapd->driver->sta_deauth == NULL)
155 return hapd->driver->sta_deauth(hapd->drv_priv, addr, reason);
159 hostapd_sta_disassoc(struct hostapd_data *hapd, const u8 *addr, int reason)
161 if (hapd->driver == NULL || hapd->driver->sta_disassoc == NULL)
163 return hapd->driver->sta_disassoc(hapd->drv_priv, addr, reason);
167 hostapd_sta_remove(struct hostapd_data *hapd, const u8 *addr)
169 if (hapd->driver == NULL || hapd->driver->sta_remove == NULL)
171 return hapd->driver->sta_remove(hapd->drv_priv, addr);
175 hostapd_get_ssid(struct hostapd_data *hapd, u8 *buf, size_t len)
177 if (hapd->driver == NULL || hapd->driver->get_ssid == NULL)
179 return hapd->driver->get_ssid(hapd->conf->iface, hapd->drv_priv, buf,
184 hostapd_set_ssid(struct hostapd_data *hapd, const u8 *buf, size_t len)
186 if (hapd->driver == NULL || hapd->driver->set_ssid == NULL)
188 return hapd->driver->set_ssid(hapd->conf->iface, hapd->drv_priv, buf,
193 hostapd_send_mgmt_frame(struct hostapd_data *hapd, const void *msg, size_t len,
196 if (hapd->driver == NULL || hapd->driver->send_mgmt_frame == NULL)
198 return hapd->driver->send_mgmt_frame(hapd->drv_priv, msg, len, flags);
202 hostapd_set_assoc_ap(struct hostapd_data *hapd, const u8 *addr)
204 if (hapd->driver == NULL || hapd->driver->set_assoc_ap == NULL)
206 return hapd->driver->set_assoc_ap(hapd->drv_priv, addr);
210 hostapd_set_countermeasures(struct hostapd_data *hapd, int enabled)
212 if (hapd->driver == NULL || hapd->driver->set_countermeasures == NULL)
214 return hapd->driver->set_countermeasures(hapd->drv_priv, enabled);
218 hostapd_sta_add(const char *ifname, struct hostapd_data *hapd, const u8 *addr,
219 u16 aid, u16 capability, const u8 *supp_rates,
220 size_t supp_rates_len, int flags, u16 listen_interval,
221 const struct ht_cap_ie *ht_capabilities)
223 if (hapd->driver == NULL)
226 if (hapd->driver->sta_add2) {
227 struct hostapd_sta_add_params params;
228 os_memset(¶ms, 0, sizeof(params));
231 params.capability = capability;
232 params.supp_rates = supp_rates;
233 params.supp_rates_len = supp_rates_len;
234 params.flags = flags;
235 params.listen_interval = listen_interval;
236 params.ht_capabilities = ht_capabilities;
237 return hapd->driver->sta_add2(ifname, hapd->drv_priv, ¶ms);
240 if (hapd->driver->sta_add == NULL)
242 return hapd->driver->sta_add(ifname, hapd->drv_priv, addr, aid,
243 capability, (u8 *) supp_rates,
245 flags, listen_interval);
249 hostapd_get_inact_sec(struct hostapd_data *hapd, const u8 *addr)
251 if (hapd->driver == NULL || hapd->driver->get_inact_sec == NULL)
253 return hapd->driver->get_inact_sec(hapd->drv_priv, addr);
257 hostapd_set_freq(struct hostapd_data *hapd, int mode, int freq, int ht_enabled,
258 int sec_channel_offset)
260 if (hapd->driver == NULL)
262 if (hapd->driver->set_freq2) {
263 struct hostapd_freq_params data;
264 os_memset(&data, 0, sizeof(data));
267 data.ht_enabled = ht_enabled;
268 data.sec_channel_offset = sec_channel_offset;
269 return hapd->driver->set_freq2(hapd->drv_priv, &data);
272 if (hapd->driver->set_freq == NULL)
274 return hapd->driver->set_freq(hapd->drv_priv, mode, freq);
278 hostapd_set_rts(struct hostapd_data *hapd, int rts)
280 if (hapd->driver == NULL || hapd->driver->set_rts == NULL)
282 return hapd->driver->set_rts(hapd->drv_priv, rts);
286 hostapd_get_rts(struct hostapd_data *hapd, int *rts)
288 if (hapd->driver == NULL || hapd->driver->get_rts == NULL)
290 return hapd->driver->get_rts(hapd->drv_priv, rts);
294 hostapd_set_frag(struct hostapd_data *hapd, int frag)
296 if (hapd->driver == NULL || hapd->driver->set_frag == NULL)
298 return hapd->driver->set_frag(hapd->drv_priv, frag);
302 hostapd_get_frag(struct hostapd_data *hapd, int *frag)
304 if (hapd->driver == NULL || hapd->driver->get_frag == NULL)
306 return hapd->driver->get_frag(hapd->drv_priv, frag);
310 hostapd_set_retry(struct hostapd_data *hapd, int short_retry, int long_retry)
312 if (hapd->driver == NULL || hapd->driver->set_retry == NULL)
314 return hapd->driver->set_retry(hapd->drv_priv, short_retry,
319 hostapd_get_retry(struct hostapd_data *hapd, int *short_retry, int *long_retry)
321 if (hapd->driver == NULL || hapd->driver->get_retry == NULL)
323 return hapd->driver->get_retry(hapd->drv_priv, short_retry,
328 hostapd_sta_set_flags(struct hostapd_data *hapd, u8 *addr,
329 int total_flags, int flags_or, int flags_and)
331 if (hapd->driver == NULL || hapd->driver->sta_set_flags == NULL)
333 return hapd->driver->sta_set_flags(hapd->drv_priv, addr, total_flags,
334 flags_or, flags_and);
338 hostapd_set_rate_sets(struct hostapd_data *hapd, int *supp_rates,
339 int *basic_rates, int mode)
341 if (hapd->driver == NULL || hapd->driver->set_rate_sets == NULL)
343 return hapd->driver->set_rate_sets(hapd->drv_priv, supp_rates,
348 hostapd_set_country(struct hostapd_data *hapd, const char *country)
350 if (hapd->driver == NULL ||
351 hapd->driver->set_country == NULL)
353 return hapd->driver->set_country(hapd->drv_priv, country);
357 hostapd_set_ieee80211d(struct hostapd_data *hapd, int enabled)
359 if (hapd->driver == NULL ||
360 hapd->driver->set_ieee80211d == NULL)
362 return hapd->driver->set_ieee80211d(hapd->drv_priv, enabled);
366 hostapd_sta_clear_stats(struct hostapd_data *hapd, const u8 *addr)
368 if (hapd->driver == NULL || hapd->driver->sta_clear_stats == NULL)
370 return hapd->driver->sta_clear_stats(hapd->drv_priv, addr);
374 hostapd_set_beacon(const char *ifname, struct hostapd_data *hapd,
375 u8 *head, size_t head_len,
376 u8 *tail, size_t tail_len)
378 if (hapd->driver == NULL || hapd->driver->set_beacon == NULL)
380 return hapd->driver->set_beacon(ifname, hapd->drv_priv, head, head_len,
385 hostapd_set_internal_bridge(struct hostapd_data *hapd, int value)
387 if (hapd->driver == NULL || hapd->driver->set_internal_bridge == NULL)
389 return hapd->driver->set_internal_bridge(hapd->drv_priv, value);
393 hostapd_set_beacon_int(struct hostapd_data *hapd, int value)
395 if (hapd->driver == NULL || hapd->driver->set_beacon_int == NULL)
397 return hapd->driver->set_beacon_int(hapd->drv_priv, value);
401 hostapd_set_dtim_period(struct hostapd_data *hapd, int value)
403 if (hapd->driver == NULL || hapd->driver->set_dtim_period == NULL)
405 return hapd->driver->set_dtim_period(hapd->conf->iface, hapd->drv_priv,
410 hostapd_set_broadcast_ssid(struct hostapd_data *hapd, int value)
412 if (hapd->driver == NULL || hapd->driver->set_broadcast_ssid == NULL)
414 return hapd->driver->set_broadcast_ssid(hapd->drv_priv, value);
418 hostapd_set_cts_protect(struct hostapd_data *hapd, int value)
420 if (hapd->driver == NULL || hapd->driver->set_cts_protect == NULL)
422 return hapd->driver->set_cts_protect(hapd->drv_priv, value);
426 hostapd_set_key_tx_rx_threshold(struct hostapd_data *hapd, int value)
428 if (hapd->driver == NULL ||
429 hapd->driver->set_key_tx_rx_threshold == NULL)
431 return hapd->driver->set_key_tx_rx_threshold(hapd->drv_priv, value);
435 hostapd_set_preamble(struct hostapd_data *hapd, int value)
437 if (hapd->driver == NULL || hapd->driver->set_preamble == NULL)
439 return hapd->driver->set_preamble(hapd->drv_priv, value);
443 hostapd_set_short_slot_time(struct hostapd_data *hapd, int value)
445 if (hapd->driver == NULL || hapd->driver->set_short_slot_time == NULL)
447 return hapd->driver->set_short_slot_time(hapd->drv_priv, value);
451 hostapd_set_tx_queue_params(struct hostapd_data *hapd, int queue, int aifs,
452 int cw_min, int cw_max, int burst_time)
454 if (hapd->driver == NULL || hapd->driver->set_tx_queue_params == NULL)
456 return hapd->driver->set_tx_queue_params(hapd->drv_priv, queue, aifs,
457 cw_min, cw_max, burst_time);
461 hostapd_bss_add(struct hostapd_data *hapd, const char *ifname, const u8 *bssid)
463 if (hapd->driver == NULL || hapd->driver->bss_add == NULL)
465 return hapd->driver->bss_add(hapd->drv_priv, ifname, bssid);
469 hostapd_bss_remove(struct hostapd_data *hapd, const char *ifname)
471 if (hapd->driver == NULL || hapd->driver->bss_remove == NULL)
473 return hapd->driver->bss_remove(hapd->drv_priv, ifname);
477 hostapd_valid_bss_mask(struct hostapd_data *hapd, const u8 *addr,
480 if (hapd->driver == NULL || hapd->driver->valid_bss_mask == NULL)
482 return hapd->driver->valid_bss_mask(hapd->drv_priv, addr, mask);
486 hostapd_if_add(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
487 char *ifname, const u8 *addr)
489 if (hapd->driver == NULL || hapd->driver->if_add == NULL)
491 return hapd->driver->if_add(hapd->conf->iface, hapd->drv_priv, type,
496 hostapd_if_update(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
497 char *ifname, const u8 *addr)
499 if (hapd->driver == NULL || hapd->driver->if_update == NULL)
501 return hapd->driver->if_update(hapd->drv_priv, type, ifname, addr);
505 hostapd_if_remove(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
506 char *ifname, const u8 *addr)
508 if (hapd->driver == NULL || hapd->driver->if_remove == NULL)
510 return hapd->driver->if_remove(hapd->drv_priv, type, ifname, addr);
514 hostapd_passive_scan(struct hostapd_data *hapd, int now, int our_mode_only,
515 int interval, int _listen, int *channel,
518 if (hapd->driver == NULL || hapd->driver->passive_scan == NULL)
520 return hapd->driver->passive_scan(hapd->drv_priv, now, our_mode_only,
521 interval, _listen, channel, last_rx);
524 static inline struct hostapd_hw_modes *
525 hostapd_get_hw_feature_data(struct hostapd_data *hapd, u16 *num_modes,
528 if (hapd->driver == NULL || hapd->driver->get_hw_feature_data == NULL)
530 return hapd->driver->get_hw_feature_data(hapd->drv_priv, num_modes,
535 hostapd_set_sta_vlan(const char *ifname, struct hostapd_data *hapd,
536 const u8 *addr, int vlan_id)
538 if (hapd->driver == NULL || hapd->driver->set_sta_vlan == NULL)
540 return hapd->driver->set_sta_vlan(hapd->drv_priv, addr, ifname, vlan_id);
544 hostapd_driver_commit(struct hostapd_data *hapd)
546 if (hapd->driver == NULL || hapd->driver->commit == NULL)
548 return hapd->driver->commit(hapd->drv_priv);
552 hostapd_set_radius_acl_auth(struct hostapd_data *hapd, const u8 *mac,
553 int accepted, u32 session_timeout)
555 if (hapd->driver == NULL || hapd->driver->set_radius_acl_auth == NULL)
557 return hapd->driver->set_radius_acl_auth(hapd->drv_priv, mac, accepted,
562 hostapd_set_radius_acl_expire(struct hostapd_data *hapd, const u8 *mac)
564 if (hapd->driver == NULL ||
565 hapd->driver->set_radius_acl_expire == NULL)
567 return hapd->driver->set_radius_acl_expire(hapd->drv_priv, mac);
570 #ifdef CONFIG_IEEE80211N
572 hostapd_set_ht_params(const char *ifname, struct hostapd_data *hapd,
573 const u8 *ht_capab, size_t ht_capab_len,
574 const u8 *ht_oper, size_t ht_oper_len)
576 if (hapd->driver == NULL || hapd->driver->set_ht_params == NULL ||
577 ht_capab == NULL || ht_oper == NULL)
579 return hapd->driver->set_ht_params(
580 ifname, hapd->drv_priv, ht_capab, ht_capab_len,
581 ht_oper, ht_oper_len);
583 #endif /* CONFIG_IEEE80211N */
586 hostapd_drv_none(struct hostapd_data *hapd)
588 return hapd->driver && os_strcmp(hapd->driver->name, "none") == 0;
592 hostapd_set_wps_beacon_ie(struct hostapd_data *hapd, const u8 *ie, size_t len)
594 if (hapd->driver == NULL || hapd->driver->set_wps_beacon_ie == NULL)
596 return hapd->driver->set_wps_beacon_ie(hapd->conf->iface,
597 hapd->drv_priv, ie, len);
601 hostapd_set_wps_probe_resp_ie(struct hostapd_data *hapd, const u8 *ie,
604 if (hapd->driver == NULL ||
605 hapd->driver->set_wps_probe_resp_ie == NULL)
607 return hapd->driver->set_wps_probe_resp_ie(hapd->conf->iface,
608 hapd->drv_priv, ie, len);
611 static inline const struct hostapd_neighbor_bss *
612 hostapd_driver_get_neighbor_bss(struct hostapd_data *hapd, size_t *num)
614 if (hapd->driver == NULL || hapd->driver->get_neighbor_bss == NULL)
616 return hapd->driver->get_neighbor_bss(hapd->drv_priv, num);
619 #endif /* DRIVER_I_H */