2 * hostapd - internal driver interface wrappers
3 * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
18 #include "drivers/driver.h"
19 #include "ap/config.h"
22 hostapd_set_ieee8021x(struct hostapd_data *hapd, struct wpa_bss_params *params)
24 if (hapd->driver == NULL || hapd->driver->set_ieee8021x == NULL)
26 return hapd->driver->set_ieee8021x(hapd->drv_priv, params);
30 hostapd_set_privacy(struct hostapd_data *hapd, int enabled)
32 if (hapd->driver == NULL || hapd->driver->set_privacy == NULL)
34 return hapd->driver->set_privacy(hapd->conf->iface, hapd->drv_priv,
39 hostapd_get_seqnum(const char *ifname, struct hostapd_data *hapd,
40 const u8 *addr, int idx, u8 *seq)
42 if (hapd->driver == NULL || hapd->driver->get_seqnum == NULL)
44 return hapd->driver->get_seqnum(ifname, hapd->drv_priv, addr, idx,
49 hostapd_flush(struct hostapd_data *hapd)
51 if (hapd->driver == NULL || hapd->driver->flush == NULL)
53 return hapd->driver->flush(hapd->drv_priv);
57 hostapd_set_generic_elem(struct hostapd_data *hapd, const u8 *elem,
60 if (hapd->driver == NULL || hapd->driver->set_generic_elem == NULL)
62 return hapd->driver->set_generic_elem(hapd->conf->iface,
63 hapd->drv_priv, elem, elem_len);
67 hostapd_get_ssid(struct hostapd_data *hapd, u8 *buf, size_t len)
69 if (hapd->driver == NULL || hapd->driver->hapd_get_ssid == NULL)
71 return hapd->driver->hapd_get_ssid(hapd->conf->iface, hapd->drv_priv,
76 hostapd_set_ssid(struct hostapd_data *hapd, const u8 *buf, size_t len)
78 if (hapd->driver == NULL || hapd->driver->hapd_set_ssid == NULL)
80 return hapd->driver->hapd_set_ssid(hapd->conf->iface, hapd->drv_priv,
85 hostapd_set_freq(struct hostapd_data *hapd, int mode, int freq, int channel,
86 int ht_enabled, int sec_channel_offset)
88 struct hostapd_freq_params data;
89 if (hapd->driver == NULL)
91 if (hapd->driver->set_freq == NULL)
93 os_memset(&data, 0, sizeof(data));
96 data.channel = channel;
97 data.ht_enabled = ht_enabled;
98 data.sec_channel_offset = sec_channel_offset;
99 return hapd->driver->set_freq(hapd->drv_priv, &data);
103 hostapd_set_rts(struct hostapd_data *hapd, int rts)
105 if (hapd->driver == NULL || hapd->driver->set_rts == NULL)
107 return hapd->driver->set_rts(hapd->drv_priv, rts);
111 hostapd_set_frag(struct hostapd_data *hapd, int frag)
113 if (hapd->driver == NULL || hapd->driver->set_frag == NULL)
115 return hapd->driver->set_frag(hapd->drv_priv, frag);
119 hostapd_sta_set_flags(struct hostapd_data *hapd, u8 *addr,
120 int total_flags, int flags_or, int flags_and)
122 if (hapd->driver == NULL || hapd->driver->sta_set_flags == NULL)
124 return hapd->driver->sta_set_flags(hapd->drv_priv, addr, total_flags,
125 flags_or, flags_and);
129 hostapd_set_rate_sets(struct hostapd_data *hapd, int *supp_rates,
130 int *basic_rates, int mode)
132 if (hapd->driver == NULL || hapd->driver->set_rate_sets == NULL)
134 return hapd->driver->set_rate_sets(hapd->drv_priv, supp_rates,
139 hostapd_set_country(struct hostapd_data *hapd, const char *country)
141 if (hapd->driver == NULL ||
142 hapd->driver->set_country == NULL)
144 return hapd->driver->set_country(hapd->drv_priv, country);
148 hostapd_set_cts_protect(struct hostapd_data *hapd, int value)
150 if (hapd->driver == NULL || hapd->driver->set_cts_protect == NULL)
152 return hapd->driver->set_cts_protect(hapd->drv_priv, value);
156 hostapd_set_preamble(struct hostapd_data *hapd, int value)
158 if (hapd->driver == NULL || hapd->driver->set_preamble == NULL)
160 return hapd->driver->set_preamble(hapd->drv_priv, value);
164 hostapd_set_short_slot_time(struct hostapd_data *hapd, int value)
166 if (hapd->driver == NULL || hapd->driver->set_short_slot_time == NULL)
168 return hapd->driver->set_short_slot_time(hapd->drv_priv, value);
172 hostapd_set_tx_queue_params(struct hostapd_data *hapd, int queue, int aifs,
173 int cw_min, int cw_max, int burst_time)
175 if (hapd->driver == NULL || hapd->driver->set_tx_queue_params == NULL)
177 return hapd->driver->set_tx_queue_params(hapd->drv_priv, queue, aifs,
178 cw_min, cw_max, burst_time);
182 hostapd_valid_bss_mask(struct hostapd_data *hapd, const u8 *addr,
185 if (hapd->driver == NULL || hapd->driver->valid_bss_mask == NULL)
187 return hapd->driver->valid_bss_mask(hapd->drv_priv, addr, mask);
191 hostapd_if_add(struct hostapd_data *hapd, enum wpa_driver_if_type type,
192 const char *ifname, const u8 *addr, void *bss_ctx)
194 if (hapd->driver == NULL || hapd->driver->if_add == NULL)
196 return hapd->driver->if_add(hapd->conf->iface, hapd->drv_priv, type,
197 ifname, addr, bss_ctx);
201 hostapd_if_remove(struct hostapd_data *hapd, enum wpa_driver_if_type type,
204 if (hapd->driver == NULL || hapd->driver->if_remove == NULL)
206 return hapd->driver->if_remove(hapd->drv_priv, type, ifname);
209 static inline struct hostapd_hw_modes *
210 hostapd_get_hw_feature_data(struct hostapd_data *hapd, u16 *num_modes,
213 if (hapd->driver == NULL ||
214 hapd->driver->get_hw_feature_data == NULL)
216 return hapd->driver->get_hw_feature_data(hapd->drv_priv, num_modes,
221 hostapd_driver_commit(struct hostapd_data *hapd)
223 if (hapd->driver == NULL || hapd->driver->commit == NULL)
225 return hapd->driver->commit(hapd->drv_priv);
229 hostapd_set_ht_params(const char *ifname, struct hostapd_data *hapd,
230 const u8 *ht_capab, size_t ht_capab_len,
231 const u8 *ht_oper, size_t ht_oper_len)
233 if (hapd->driver == NULL || hapd->driver->set_ht_params == NULL ||
234 ht_capab == NULL || ht_oper == NULL)
236 return hapd->driver->set_ht_params(
237 ifname, hapd->drv_priv, ht_capab, ht_capab_len,
238 ht_oper, ht_oper_len);
242 hostapd_drv_none(struct hostapd_data *hapd)
244 return hapd->driver && os_strcmp(hapd->driver->name, "none") == 0;
247 static inline int hostapd_driver_scan(struct hostapd_data *hapd,
248 struct wpa_driver_scan_params *params)
250 if (hapd->driver && hapd->driver->scan2)
251 return hapd->driver->scan2(hapd->drv_priv, params);
255 static inline struct wpa_scan_results * hostapd_driver_get_scan_results(
256 struct hostapd_data *hapd)
258 if (hapd->driver && hapd->driver->get_scan_results2)
259 return hapd->driver->get_scan_results2(hapd->drv_priv);
263 #endif /* DRIVER_I_H */