Remove ap_config.h dependency from driver_i.h
[hostap-gosc2009.git] / src / ap / driver_i.h
blobff0e1e69d8428010b0e13b5d688115ff43d3187e
1 /*
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
10 * license.
12 * See README and COPYING for more details.
15 #ifndef DRIVER_I_H
16 #define DRIVER_I_H
18 #include "drivers/driver.h"
20 static inline int
21 hostapd_set_ieee8021x(struct hostapd_data *hapd, struct wpa_bss_params *params)
23 if (hapd->driver == NULL || hapd->driver->set_ieee8021x == NULL)
24 return 0;
25 return hapd->driver->set_ieee8021x(hapd->drv_priv, params);
28 static inline int
29 hostapd_get_seqnum(const char *ifname, struct hostapd_data *hapd,
30 const u8 *addr, int idx, u8 *seq)
32 if (hapd->driver == NULL || hapd->driver->get_seqnum == NULL)
33 return 0;
34 return hapd->driver->get_seqnum(ifname, hapd->drv_priv, addr, idx,
35 seq);
38 static inline int
39 hostapd_flush(struct hostapd_data *hapd)
41 if (hapd->driver == NULL || hapd->driver->flush == NULL)
42 return 0;
43 return hapd->driver->flush(hapd->drv_priv);
46 static inline int
47 hostapd_set_freq(struct hostapd_data *hapd, int mode, int freq, int channel,
48 int ht_enabled, int sec_channel_offset)
50 struct hostapd_freq_params data;
51 if (hapd->driver == NULL)
52 return 0;
53 if (hapd->driver->set_freq == NULL)
54 return 0;
55 os_memset(&data, 0, sizeof(data));
56 data.mode = mode;
57 data.freq = freq;
58 data.channel = channel;
59 data.ht_enabled = ht_enabled;
60 data.sec_channel_offset = sec_channel_offset;
61 return hapd->driver->set_freq(hapd->drv_priv, &data);
64 static inline int
65 hostapd_set_rts(struct hostapd_data *hapd, int rts)
67 if (hapd->driver == NULL || hapd->driver->set_rts == NULL)
68 return 0;
69 return hapd->driver->set_rts(hapd->drv_priv, rts);
72 static inline int
73 hostapd_set_frag(struct hostapd_data *hapd, int frag)
75 if (hapd->driver == NULL || hapd->driver->set_frag == NULL)
76 return 0;
77 return hapd->driver->set_frag(hapd->drv_priv, frag);
80 static inline int
81 hostapd_sta_set_flags(struct hostapd_data *hapd, u8 *addr,
82 int total_flags, int flags_or, int flags_and)
84 if (hapd->driver == NULL || hapd->driver->sta_set_flags == NULL)
85 return 0;
86 return hapd->driver->sta_set_flags(hapd->drv_priv, addr, total_flags,
87 flags_or, flags_and);
90 static inline int
91 hostapd_set_rate_sets(struct hostapd_data *hapd, int *supp_rates,
92 int *basic_rates, int mode)
94 if (hapd->driver == NULL || hapd->driver->set_rate_sets == NULL)
95 return 0;
96 return hapd->driver->set_rate_sets(hapd->drv_priv, supp_rates,
97 basic_rates, mode);
100 static inline int
101 hostapd_set_country(struct hostapd_data *hapd, const char *country)
103 if (hapd->driver == NULL ||
104 hapd->driver->set_country == NULL)
105 return 0;
106 return hapd->driver->set_country(hapd->drv_priv, country);
109 static inline int
110 hostapd_set_cts_protect(struct hostapd_data *hapd, int value)
112 if (hapd->driver == NULL || hapd->driver->set_cts_protect == NULL)
113 return 0;
114 return hapd->driver->set_cts_protect(hapd->drv_priv, value);
117 static inline int
118 hostapd_set_preamble(struct hostapd_data *hapd, int value)
120 if (hapd->driver == NULL || hapd->driver->set_preamble == NULL)
121 return 0;
122 return hapd->driver->set_preamble(hapd->drv_priv, value);
125 static inline int
126 hostapd_set_short_slot_time(struct hostapd_data *hapd, int value)
128 if (hapd->driver == NULL || hapd->driver->set_short_slot_time == NULL)
129 return 0;
130 return hapd->driver->set_short_slot_time(hapd->drv_priv, value);
133 static inline int
134 hostapd_set_tx_queue_params(struct hostapd_data *hapd, int queue, int aifs,
135 int cw_min, int cw_max, int burst_time)
137 if (hapd->driver == NULL || hapd->driver->set_tx_queue_params == NULL)
138 return 0;
139 return hapd->driver->set_tx_queue_params(hapd->drv_priv, queue, aifs,
140 cw_min, cw_max, burst_time);
143 static inline int
144 hostapd_valid_bss_mask(struct hostapd_data *hapd, const u8 *addr,
145 const u8 *mask)
147 if (hapd->driver == NULL || hapd->driver->valid_bss_mask == NULL)
148 return 1;
149 return hapd->driver->valid_bss_mask(hapd->drv_priv, addr, mask);
152 static inline struct hostapd_hw_modes *
153 hostapd_get_hw_feature_data(struct hostapd_data *hapd, u16 *num_modes,
154 u16 *flags)
156 if (hapd->driver == NULL ||
157 hapd->driver->get_hw_feature_data == NULL)
158 return NULL;
159 return hapd->driver->get_hw_feature_data(hapd->drv_priv, num_modes,
160 flags);
163 static inline int
164 hostapd_driver_commit(struct hostapd_data *hapd)
166 if (hapd->driver == NULL || hapd->driver->commit == NULL)
167 return 0;
168 return hapd->driver->commit(hapd->drv_priv);
171 static inline int
172 hostapd_set_ht_params(const char *ifname, struct hostapd_data *hapd,
173 const u8 *ht_capab, size_t ht_capab_len,
174 const u8 *ht_oper, size_t ht_oper_len)
176 if (hapd->driver == NULL || hapd->driver->set_ht_params == NULL ||
177 ht_capab == NULL || ht_oper == NULL)
178 return 0;
179 return hapd->driver->set_ht_params(
180 ifname, hapd->drv_priv, ht_capab, ht_capab_len,
181 ht_oper, ht_oper_len);
184 static inline int
185 hostapd_drv_none(struct hostapd_data *hapd)
187 return hapd->driver && os_strcmp(hapd->driver->name, "none") == 0;
190 static inline int hostapd_driver_scan(struct hostapd_data *hapd,
191 struct wpa_driver_scan_params *params)
193 if (hapd->driver && hapd->driver->scan2)
194 return hapd->driver->scan2(hapd->drv_priv, params);
195 return -1;
198 static inline struct wpa_scan_results * hostapd_driver_get_scan_results(
199 struct hostapd_data *hapd)
201 if (hapd->driver && hapd->driver->get_scan_results2)
202 return hapd->driver->get_scan_results2(hapd->drv_priv);
203 return NULL;
206 #endif /* DRIVER_I_H */