nl80211: Add support for setting channel frequency and HT20 vs. HT40
[wpasupplicant] / hostapd / driver.h
1 /*
2  * hostapd - driver interface definition
3  * Copyright (c) 2002-2007, Jouni Malinen <j@w1.fi>
4  * Copyright (c) 2007-2008, Intel Corporation
5  *
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.
9  *
10  * Alternatively, this software may be distributed under the terms of BSD
11  * license.
12  *
13  * See README and COPYING for more details.
14  */
15
16 #ifndef DRIVER_H
17 #define DRIVER_H
18
19 struct hostapd_sta_add_params {
20         const u8 *addr;
21         u16 aid;
22         u16 capability;
23         const u8 *supp_rates;
24         size_t supp_rates_len;
25         int flags;
26         u16 listen_interval;
27         const struct ht_cap_ie *ht_capabilities;
28 };
29
30 struct hostapd_freq_params {
31         int mode;
32         int freq;
33         int sec_channel_offset; /* 0 = HT40 disabled, -1 = HT40 enabled,
34                                  * secondary channel below primary, 1 = HT40
35                                  * enabled, secondary channel above primary */
36 };
37
38 enum hostapd_driver_if_type {
39         HOSTAPD_IF_VLAN, HOSTAPD_IF_WDS
40 };
41
42 struct wpa_driver_ops {
43         const char *name;               /* as appears in the config file */
44
45         void * (*init)(struct hostapd_data *hapd);
46         void * (*init_bssid)(struct hostapd_data *hapd, const u8 *bssid);
47         void (*deinit)(void *priv);
48
49         int (*wireless_event_init)(void *priv);
50         void (*wireless_event_deinit)(void *priv);
51
52         /**
53          * set_8021x - enable/disable IEEE 802.1X support
54          * @ifname: Interface name (for multi-SSID/VLAN support)
55          * @priv: driver private data
56          * @enabled: 1 = enable, 0 = disable
57          *
58          * Returns: 0 on success, -1 on failure
59          *
60          * Configure the kernel driver to enable/disable 802.1X support.
61          * This may be an empty function if 802.1X support is always enabled.
62          */
63         int (*set_ieee8021x)(const char *ifname, void *priv, int enabled);
64
65         /**
66          * set_privacy - enable/disable privacy
67          * @priv: driver private data
68          * @enabled: 1 = privacy enabled, 0 = disabled
69          *
70          * Return: 0 on success, -1 on failure
71          *
72          * Configure privacy.
73          */
74         int (*set_privacy)(const char *ifname, void *priv, int enabled);
75
76         int (*set_encryption)(const char *ifname, void *priv, const char *alg,
77                               const u8 *addr, int idx,
78                               const u8 *key, size_t key_len, int txkey);
79         int (*get_seqnum)(const char *ifname, void *priv, const u8 *addr,
80                           int idx, u8 *seq);
81         int (*get_seqnum_igtk)(const char *ifname, void *priv, const u8 *addr,
82                                int idx, u8 *seq);
83         int (*flush)(void *priv);
84         int (*set_generic_elem)(const char *ifname, void *priv, const u8 *elem,
85                                 size_t elem_len);
86
87         int (*read_sta_data)(void *priv, struct hostap_sta_driver_data *data,
88                              const u8 *addr);
89         int (*send_eapol)(void *priv, const u8 *addr, const u8 *data,
90                           size_t data_len, int encrypt, const u8 *own_addr);
91         int (*sta_deauth)(void *priv, const u8 *addr, int reason);
92         int (*sta_disassoc)(void *priv, const u8 *addr, int reason);
93         int (*sta_remove)(void *priv, const u8 *addr);
94         int (*get_ssid)(const char *ifname, void *priv, u8 *buf, int len);
95         int (*set_ssid)(const char *ifname, void *priv, const u8 *buf,
96                         int len);
97         int (*set_countermeasures)(void *priv, int enabled);
98         int (*send_mgmt_frame)(void *priv, const void *msg, size_t len,
99                                int flags);
100         int (*set_assoc_ap)(void *priv, const u8 *addr);
101         /* note: sta_add() is deprecated; use sta_add2() instead */
102         int (*sta_add)(const char *ifname, void *priv, const u8 *addr, u16 aid,
103                        u16 capability, u8 *supp_rates, size_t supp_rates_len,
104                        int flags, u16 listen_interval);
105         int (*sta_add2)(const char *ifname, void *priv,
106                         struct hostapd_sta_add_params *params);
107         int (*get_inact_sec)(void *priv, const u8 *addr);
108         int (*sta_clear_stats)(void *priv, const u8 *addr);
109
110         /* note: set_freq() is deprecated; use sta_freq() instead */
111         int (*set_freq)(void *priv, int mode, int freq);
112         int (*set_freq2)(void *priv, struct hostapd_freq_params *freq);
113         int (*set_rts)(void *priv, int rts);
114         int (*get_rts)(void *priv, int *rts);
115         int (*set_frag)(void *priv, int frag);
116         int (*get_frag)(void *priv, int *frag);
117         int (*set_retry)(void *priv, int short_retry, int long_retry);
118         int (*get_retry)(void *priv, int *short_retry, int *long_retry);
119
120         int (*sta_set_flags)(void *priv, const u8 *addr,
121                              int total_flags, int flags_or, int flags_and);
122         int (*set_rate_sets)(void *priv, int *supp_rates, int *basic_rates,
123                              int mode);
124         int (*set_regulatory_domain)(void *priv, unsigned int rd);
125         int (*set_country)(void *priv, const char *country);
126         int (*set_ieee80211d)(void *priv, int enabled);
127         int (*set_beacon)(const char *ifname, void *priv,
128                           u8 *head, size_t head_len,
129                           u8 *tail, size_t tail_len);
130
131         /* Configure internal bridge:
132          * 0 = disabled, i.e., client separation is enabled (no bridging of
133          *     packets between associated STAs
134          * 1 = enabled, i.e., bridge packets between associated STAs (default)
135          */
136         int (*set_internal_bridge)(void *priv, int value);
137         int (*set_beacon_int)(void *priv, int value);
138         int (*set_dtim_period)(const char *ifname, void *priv, int value);
139         /* Configure broadcast SSID mode:
140          * 0 = include SSID in Beacon frames and reply to Probe Request frames
141          *     that use broadcast SSID
142          * 1 = hide SSID from Beacon frames and ignore Probe Request frames for
143          *     broadcast SSID
144          */
145         int (*set_broadcast_ssid)(void *priv, int value);
146         int (*set_cts_protect)(void *priv, int value);
147         int (*set_key_tx_rx_threshold)(void *priv, int value);
148         int (*set_preamble)(void *priv, int value);
149         int (*set_short_slot_time)(void *priv, int value);
150         int (*set_tx_queue_params)(void *priv, int queue, int aifs, int cw_min,
151                                    int cw_max, int burst_time);
152         int (*bss_add)(void *priv, const char *ifname, const u8 *bssid);
153         int (*bss_remove)(void *priv, const char *ifname);
154         int (*valid_bss_mask)(void *priv, const u8 *addr, const u8 *mask);
155         int (*passive_scan)(void *priv, int now, int our_mode_only,
156                             int interval, int _listen, int *channel,
157                             int *last_rx);
158         struct hostapd_hw_modes * (*get_hw_feature_data)(void *priv,
159                                                          u16 *num_modes,
160                                                          u16 *flags);
161         int (*if_add)(const char *iface, void *priv,
162                       enum hostapd_driver_if_type type, char *ifname,
163                       const u8 *addr);
164         int (*if_update)(void *priv, enum hostapd_driver_if_type type,
165                          char *ifname, const u8 *addr);
166         int (*if_remove)(void *priv, enum hostapd_driver_if_type type,
167                          const char *ifname, const u8 *addr);
168         int (*set_sta_vlan)(void *priv, const u8 *addr, const char *ifname,
169                             int vlan_id);
170         /**
171          * commit - Optional commit changes handler
172          * @priv: driver private data
173          * Returns: 0 on success, -1 on failure
174          *
175          * This optional handler function can be registered if the driver
176          * interface implementation needs to commit changes (e.g., by setting
177          * network interface up) at the end of initial configuration. If set,
178          * this handler will be called after initial setup has been completed.
179          */
180         int (*commit)(void *priv);
181
182         int (*send_ether)(void *priv, const u8 *dst, const u8 *src, u16 proto,
183                           const u8 *data, size_t data_len);
184
185         int (*set_radius_acl_auth)(void *priv, const u8 *mac, int accepted, 
186                                    u32 session_timeout);
187         int (*set_radius_acl_expire)(void *priv, const u8 *mac);
188
189         int (*set_ht_params)(const char *ifname, void *priv,
190                              const u8 *ht_capab, size_t ht_capab_len,
191                              const u8 *ht_oper, size_t ht_oper_len);
192
193         int (*set_wps_beacon_ie)(const char *ifname, void *priv,
194                                  const u8 *ie, size_t len);
195         int (*set_wps_probe_resp_ie)(const char *ifname, void *priv,
196                                      const u8 *ie, size_t len);
197 };
198
199 static inline void *
200 hostapd_driver_init(struct hostapd_data *hapd)
201 {
202         if (hapd->driver == NULL || hapd->driver->init == NULL)
203                 return NULL;
204         return hapd->driver->init(hapd);
205 }
206
207 static inline void *
208 hostapd_driver_init_bssid(struct hostapd_data *hapd, const u8 *bssid)
209 {
210         if (hapd->driver == NULL || hapd->driver->init_bssid == NULL)
211                 return NULL;
212         return hapd->driver->init_bssid(hapd, bssid);
213 }
214
215 static inline void
216 hostapd_driver_deinit(struct hostapd_data *hapd)
217 {
218         if (hapd->driver == NULL || hapd->driver->deinit == NULL)
219                 return;
220         hapd->driver->deinit(hapd->drv_priv);
221 }
222
223 static inline int
224 hostapd_wireless_event_init(struct hostapd_data *hapd)
225 {
226         if (hapd->driver == NULL ||
227             hapd->driver->wireless_event_init == NULL)
228                 return 0;
229         return hapd->driver->wireless_event_init(hapd->drv_priv);
230 }
231
232 static inline void
233 hostapd_wireless_event_deinit(struct hostapd_data *hapd)
234 {
235         if (hapd->driver == NULL ||
236             hapd->driver->wireless_event_deinit == NULL)
237                 return;
238         hapd->driver->wireless_event_deinit(hapd->drv_priv);
239 }
240
241 static inline int
242 hostapd_set_ieee8021x(const char *ifname, struct hostapd_data *hapd,
243                       int enabled)
244 {
245         if (hapd->driver == NULL || hapd->driver->set_ieee8021x == NULL)
246                 return 0;
247         return hapd->driver->set_ieee8021x(ifname, hapd->drv_priv, enabled);
248 }
249
250 static inline int
251 hostapd_set_privacy(struct hostapd_data *hapd, int enabled)
252 {
253         if (hapd->driver == NULL || hapd->driver->set_privacy == NULL)
254                 return 0;
255         return hapd->driver->set_privacy(hapd->conf->iface, hapd->drv_priv,
256                                          enabled);
257 }
258
259 static inline int
260 hostapd_set_encryption(const char *ifname, struct hostapd_data *hapd,
261                        const char *alg, const u8 *addr, int idx,
262                        u8 *key, size_t key_len, int txkey)
263 {
264         if (hapd->driver == NULL || hapd->driver->set_encryption == NULL)
265                 return 0;
266         return hapd->driver->set_encryption(ifname, hapd->drv_priv, alg, addr,
267                                             idx, key, key_len, txkey);
268 }
269
270 static inline int
271 hostapd_get_seqnum(const char *ifname, struct hostapd_data *hapd,
272                    const u8 *addr, int idx, u8 *seq)
273 {
274         if (hapd->driver == NULL || hapd->driver->get_seqnum == NULL)
275                 return 0;
276         return hapd->driver->get_seqnum(ifname, hapd->drv_priv, addr, idx,
277                                         seq);
278 }
279
280 static inline int
281 hostapd_get_seqnum_igtk(const char *ifname, struct hostapd_data *hapd,
282                         const u8 *addr, int idx, u8 *seq)
283 {
284         if (hapd->driver == NULL || hapd->driver->get_seqnum_igtk == NULL)
285                 return -1;
286         return hapd->driver->get_seqnum_igtk(ifname, hapd->drv_priv, addr, idx,
287                                              seq);
288 }
289
290 static inline int
291 hostapd_flush(struct hostapd_data *hapd)
292 {
293         if (hapd->driver == NULL || hapd->driver->flush == NULL)
294                 return 0;
295         return hapd->driver->flush(hapd->drv_priv);
296 }
297
298 static inline int
299 hostapd_set_generic_elem(struct hostapd_data *hapd, const u8 *elem,
300                          size_t elem_len)
301 {
302         if (hapd->driver == NULL || hapd->driver->set_generic_elem == NULL)
303                 return 0;
304         return hapd->driver->set_generic_elem(hapd->conf->iface,
305                                               hapd->drv_priv, elem, elem_len);
306 }
307
308 static inline int
309 hostapd_read_sta_data(struct hostapd_data *hapd,
310                       struct hostap_sta_driver_data *data, const u8 *addr)
311 {
312         if (hapd->driver == NULL || hapd->driver->read_sta_data == NULL)
313                 return -1;
314         return hapd->driver->read_sta_data(hapd->drv_priv, data, addr);
315 }
316
317 static inline int
318 hostapd_send_eapol(struct hostapd_data *hapd, const u8 *addr, const u8 *data,
319                    size_t data_len, int encrypt)
320 {
321         if (hapd->driver == NULL || hapd->driver->send_eapol == NULL)
322                 return 0;
323         return hapd->driver->send_eapol(hapd->drv_priv, addr, data, data_len,
324                                         encrypt, hapd->own_addr);
325 }
326
327 static inline int
328 hostapd_sta_deauth(struct hostapd_data *hapd, const u8 *addr, int reason)
329 {
330         if (hapd->driver == NULL || hapd->driver->sta_deauth == NULL)
331                 return 0;
332         return hapd->driver->sta_deauth(hapd->drv_priv, addr, reason);
333 }
334
335 static inline int
336 hostapd_sta_disassoc(struct hostapd_data *hapd, const u8 *addr, int reason)
337 {
338         if (hapd->driver == NULL || hapd->driver->sta_disassoc == NULL)
339                 return 0;
340         return hapd->driver->sta_disassoc(hapd->drv_priv, addr, reason);
341 }
342
343 static inline int
344 hostapd_sta_remove(struct hostapd_data *hapd, const u8 *addr)
345 {
346         if (hapd->driver == NULL || hapd->driver->sta_remove == NULL)
347                 return 0;
348         return hapd->driver->sta_remove(hapd->drv_priv, addr);
349 }
350
351 static inline int
352 hostapd_get_ssid(struct hostapd_data *hapd, u8 *buf, size_t len)
353 {
354         if (hapd->driver == NULL || hapd->driver->get_ssid == NULL)
355                 return 0;
356         return hapd->driver->get_ssid(hapd->conf->iface, hapd->drv_priv, buf,
357                                       len);
358 }
359
360 static inline int
361 hostapd_set_ssid(struct hostapd_data *hapd, const u8 *buf, size_t len)
362 {
363         if (hapd->driver == NULL || hapd->driver->set_ssid == NULL)
364                 return 0;
365         return hapd->driver->set_ssid(hapd->conf->iface, hapd->drv_priv, buf,
366                                       len);
367 }
368
369 static inline int
370 hostapd_send_mgmt_frame(struct hostapd_data *hapd, const void *msg, size_t len,
371                         int flags)
372 {
373         if (hapd->driver == NULL || hapd->driver->send_mgmt_frame == NULL)
374                 return 0;
375         return hapd->driver->send_mgmt_frame(hapd->drv_priv, msg, len, flags);
376 }
377
378 static inline int
379 hostapd_set_assoc_ap(struct hostapd_data *hapd, const u8 *addr)
380 {
381         if (hapd->driver == NULL || hapd->driver->set_assoc_ap == NULL)
382                 return 0;
383         return hapd->driver->set_assoc_ap(hapd->drv_priv, addr);
384 }
385
386 static inline int
387 hostapd_set_countermeasures(struct hostapd_data *hapd, int enabled)
388 {
389         if (hapd->driver == NULL || hapd->driver->set_countermeasures == NULL)
390                 return 0;
391         return hapd->driver->set_countermeasures(hapd->drv_priv, enabled);
392 }
393
394 static inline int
395 hostapd_sta_add(const char *ifname, struct hostapd_data *hapd, const u8 *addr,
396                 u16 aid, u16 capability, const u8 *supp_rates,
397                 size_t supp_rates_len, int flags, u16 listen_interval,
398                 const struct ht_cap_ie *ht_capabilities)
399 {
400         if (hapd->driver == NULL)
401                 return 0;
402
403         if (hapd->driver->sta_add2) {
404                 struct hostapd_sta_add_params params;
405                 os_memset(&params, 0, sizeof(params));
406                 params.addr = addr;
407                 params.aid = aid;
408                 params.capability = capability;
409                 params.supp_rates = supp_rates;
410                 params.supp_rates_len = supp_rates_len;
411                 params.flags = flags;
412                 params.listen_interval = listen_interval;
413                 params.ht_capabilities = ht_capabilities;
414                 return hapd->driver->sta_add2(ifname, hapd->drv_priv, &params);
415         }
416
417         if (hapd->driver->sta_add == NULL)
418                 return 0;
419         return hapd->driver->sta_add(ifname, hapd->drv_priv, addr, aid,
420                                      capability, (u8 *) supp_rates,
421                                      supp_rates_len,
422                                      flags, listen_interval);
423 }
424
425 static inline int
426 hostapd_get_inact_sec(struct hostapd_data *hapd, const u8 *addr)
427 {
428         if (hapd->driver == NULL || hapd->driver->get_inact_sec == NULL)
429                 return 0;
430         return hapd->driver->get_inact_sec(hapd->drv_priv, addr);
431 }
432
433 static inline int
434 hostapd_set_freq(struct hostapd_data *hapd, int mode, int freq,
435                  int sec_channel_offset)
436 {
437         if (hapd->driver == NULL)
438                 return 0;
439         if (hapd->driver->set_freq2) {
440                 struct hostapd_freq_params data;
441                 os_memset(&data, 0, sizeof(data));
442                 data.mode = mode;
443                 data.freq = freq;
444                 data.sec_channel_offset = sec_channel_offset;
445                 return hapd->driver->set_freq2(hapd->drv_priv, &data);
446         }
447
448         if (hapd->driver->set_freq == NULL)
449                 return 0;
450         return hapd->driver->set_freq(hapd->drv_priv, mode, freq);
451 }
452
453 static inline int
454 hostapd_set_rts(struct hostapd_data *hapd, int rts)
455 {
456         if (hapd->driver == NULL || hapd->driver->set_rts == NULL)
457                 return 0;
458         return hapd->driver->set_rts(hapd->drv_priv, rts);
459 }
460
461 static inline int
462 hostapd_get_rts(struct hostapd_data *hapd, int *rts)
463 {
464         if (hapd->driver == NULL || hapd->driver->get_rts == NULL)
465                 return 0;
466         return hapd->driver->get_rts(hapd->drv_priv, rts);
467 }
468
469 static inline int
470 hostapd_set_frag(struct hostapd_data *hapd, int frag)
471 {
472         if (hapd->driver == NULL || hapd->driver->set_frag == NULL)
473                 return 0;
474         return hapd->driver->set_frag(hapd->drv_priv, frag);
475 }
476
477 static inline int
478 hostapd_get_frag(struct hostapd_data *hapd, int *frag)
479 {
480         if (hapd->driver == NULL || hapd->driver->get_frag == NULL)
481                 return 0;
482         return hapd->driver->get_frag(hapd->drv_priv, frag);
483 }
484
485 static inline int
486 hostapd_set_retry(struct hostapd_data *hapd, int short_retry, int long_retry)
487 {
488         if (hapd->driver == NULL || hapd->driver->set_retry == NULL)
489                 return 0;
490         return hapd->driver->set_retry(hapd->drv_priv, short_retry,
491                                        long_retry);
492 }
493
494 static inline int
495 hostapd_get_retry(struct hostapd_data *hapd, int *short_retry, int *long_retry)
496 {
497         if (hapd->driver == NULL || hapd->driver->get_retry == NULL)
498                 return 0;
499         return hapd->driver->get_retry(hapd->drv_priv, short_retry,
500                                        long_retry);
501 }
502
503 static inline int
504 hostapd_sta_set_flags(struct hostapd_data *hapd, u8 *addr,
505                       int total_flags, int flags_or, int flags_and)
506 {
507         if (hapd->driver == NULL || hapd->driver->sta_set_flags == NULL)
508                 return 0;
509         return hapd->driver->sta_set_flags(hapd->drv_priv, addr, total_flags,
510                                            flags_or, flags_and);
511 }
512
513 static inline int
514 hostapd_set_rate_sets(struct hostapd_data *hapd, int *supp_rates,
515                       int *basic_rates, int mode)
516 {
517         if (hapd->driver == NULL || hapd->driver->set_rate_sets == NULL)
518                 return 0;
519         return hapd->driver->set_rate_sets(hapd->drv_priv, supp_rates,
520                                            basic_rates, mode);
521 }
522
523 static inline int
524 hostapd_set_regulatory_domain(struct hostapd_data *hapd, unsigned int rd)
525 {
526         if (hapd->driver == NULL ||
527             hapd->driver->set_regulatory_domain == NULL)
528                 return 0;
529         return hapd->driver->set_regulatory_domain(hapd->drv_priv, rd);
530 }
531
532 static inline int
533 hostapd_set_country(struct hostapd_data *hapd, const char *country)
534 {
535         if (hapd->driver == NULL ||
536             hapd->driver->set_country == NULL)
537                 return 0;
538         return hapd->driver->set_country(hapd->drv_priv, country);
539 }
540
541 static inline int
542 hostapd_set_ieee80211d(struct hostapd_data *hapd, int enabled)
543 {
544         if (hapd->driver == NULL ||
545             hapd->driver->set_ieee80211d == NULL)
546                 return 0;
547         return hapd->driver->set_ieee80211d(hapd->drv_priv, enabled);
548 }
549
550 static inline int
551 hostapd_sta_clear_stats(struct hostapd_data *hapd, const u8 *addr)
552 {
553         if (hapd->driver == NULL || hapd->driver->sta_clear_stats == NULL)
554                 return 0;
555         return hapd->driver->sta_clear_stats(hapd->drv_priv, addr);
556 }
557
558 static inline int
559 hostapd_set_beacon(const char *ifname, struct hostapd_data *hapd,
560                    u8 *head, size_t head_len,
561                    u8 *tail, size_t tail_len)
562 {
563         if (hapd->driver == NULL || hapd->driver->set_beacon == NULL)
564                 return 0;
565         return hapd->driver->set_beacon(ifname, hapd->drv_priv, head, head_len,
566                                         tail, tail_len);
567 }
568
569 static inline int
570 hostapd_set_internal_bridge(struct hostapd_data *hapd, int value)
571 {
572         if (hapd->driver == NULL || hapd->driver->set_internal_bridge == NULL)
573                 return 0;
574         return hapd->driver->set_internal_bridge(hapd->drv_priv, value);
575 }
576
577 static inline int
578 hostapd_set_beacon_int(struct hostapd_data *hapd, int value)
579 {
580         if (hapd->driver == NULL || hapd->driver->set_beacon_int == NULL)
581                 return 0;
582         return hapd->driver->set_beacon_int(hapd->drv_priv, value);
583 }
584
585 static inline int
586 hostapd_set_dtim_period(struct hostapd_data *hapd, int value)
587 {
588         if (hapd->driver == NULL || hapd->driver->set_dtim_period == NULL)
589                 return 0;
590         return hapd->driver->set_dtim_period(hapd->conf->iface, hapd->drv_priv,
591                                              value);
592 }
593
594 static inline int
595 hostapd_set_broadcast_ssid(struct hostapd_data *hapd, int value)
596 {
597         if (hapd->driver == NULL || hapd->driver->set_broadcast_ssid == NULL)
598                 return 0;
599         return hapd->driver->set_broadcast_ssid(hapd->drv_priv, value);
600 }
601
602 static inline int
603 hostapd_set_cts_protect(struct hostapd_data *hapd, int value)
604 {
605         if (hapd->driver == NULL || hapd->driver->set_cts_protect == NULL)
606                 return 0;
607         return hapd->driver->set_cts_protect(hapd->drv_priv, value);
608 }
609
610 static inline int
611 hostapd_set_key_tx_rx_threshold(struct hostapd_data *hapd, int value)
612 {
613         if (hapd->driver == NULL ||
614             hapd->driver->set_key_tx_rx_threshold == NULL)
615                 return 0;
616         return hapd->driver->set_key_tx_rx_threshold(hapd->drv_priv, value);
617 }
618
619 static inline int
620 hostapd_set_preamble(struct hostapd_data *hapd, int value)
621 {
622         if (hapd->driver == NULL || hapd->driver->set_preamble == NULL)
623                 return 0;
624         return hapd->driver->set_preamble(hapd->drv_priv, value);
625 }
626
627 static inline int
628 hostapd_set_short_slot_time(struct hostapd_data *hapd, int value)
629 {
630         if (hapd->driver == NULL || hapd->driver->set_short_slot_time == NULL)
631                 return 0;
632         return hapd->driver->set_short_slot_time(hapd->drv_priv, value);
633 }
634
635 static inline int
636 hostapd_set_tx_queue_params(struct hostapd_data *hapd, int queue, int aifs,
637                             int cw_min, int cw_max, int burst_time)
638 {
639         if (hapd->driver == NULL || hapd->driver->set_tx_queue_params == NULL)
640                 return 0;
641         return hapd->driver->set_tx_queue_params(hapd->drv_priv, queue, aifs,
642                                                  cw_min, cw_max, burst_time);
643 }
644
645 static inline int
646 hostapd_bss_add(struct hostapd_data *hapd, const char *ifname, const u8 *bssid)
647 {
648         if (hapd->driver == NULL || hapd->driver->bss_add == NULL)
649                 return 0;
650         return hapd->driver->bss_add(hapd->drv_priv, ifname, bssid);
651 }
652
653 static inline int
654 hostapd_bss_remove(struct hostapd_data *hapd, const char *ifname)
655 {
656         if (hapd->driver == NULL || hapd->driver->bss_remove == NULL)
657                 return 0;
658         return hapd->driver->bss_remove(hapd->drv_priv, ifname);
659 }
660
661 static inline int
662 hostapd_valid_bss_mask(struct hostapd_data *hapd, const u8 *addr,
663                        const u8 *mask)
664 {
665         if (hapd->driver == NULL || hapd->driver->valid_bss_mask == NULL)
666                 return 1;
667         return hapd->driver->valid_bss_mask(hapd->drv_priv, addr, mask);
668 }
669
670 static inline int
671 hostapd_if_add(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
672                char *ifname, const u8 *addr)
673 {
674         if (hapd->driver == NULL || hapd->driver->if_add == NULL)
675                 return -1;
676         return hapd->driver->if_add(hapd->conf->iface, hapd->drv_priv, type,
677                                     ifname, addr);
678 }
679
680 static inline int
681 hostapd_if_update(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
682                   char *ifname, const u8 *addr)
683 {
684         if (hapd->driver == NULL || hapd->driver->if_update == NULL)
685                 return -1;
686         return hapd->driver->if_update(hapd->drv_priv, type, ifname, addr);
687 }
688
689 static inline int
690 hostapd_if_remove(struct hostapd_data *hapd, enum hostapd_driver_if_type type,
691                   char *ifname, const u8 *addr)
692 {
693         if (hapd->driver == NULL || hapd->driver->if_remove == NULL)
694                 return -1;
695         return hapd->driver->if_remove(hapd->drv_priv, type, ifname, addr);
696 }
697
698 static inline int
699 hostapd_passive_scan(struct hostapd_data *hapd, int now, int our_mode_only,
700                      int interval, int _listen, int *channel,
701                      int *last_rx)
702 {
703         if (hapd->driver == NULL || hapd->driver->passive_scan == NULL)
704                 return -1;
705         return hapd->driver->passive_scan(hapd->drv_priv, now, our_mode_only,
706                                           interval, _listen, channel, last_rx);
707 }
708
709 static inline struct hostapd_hw_modes *
710 hostapd_get_hw_feature_data(struct hostapd_data *hapd, u16 *num_modes,
711                             u16 *flags)
712 {
713         if (hapd->driver == NULL || hapd->driver->get_hw_feature_data == NULL)
714                 return NULL;
715         return hapd->driver->get_hw_feature_data(hapd->drv_priv, num_modes,
716                                                  flags);
717 }
718
719 static inline int
720 hostapd_set_sta_vlan(const char *ifname, struct hostapd_data *hapd,
721                      const u8 *addr, int vlan_id)
722 {
723         if (hapd->driver == NULL || hapd->driver->set_sta_vlan == NULL)
724                 return 0;
725         return hapd->driver->set_sta_vlan(hapd->drv_priv, addr, ifname, vlan_id);
726 }
727
728 static inline int
729 hostapd_driver_commit(struct hostapd_data *hapd)
730 {
731         if (hapd->driver == NULL || hapd->driver->commit == NULL)
732                 return 0;
733         return hapd->driver->commit(hapd->drv_priv);
734 }
735
736 static inline int
737 hostapd_set_radius_acl_auth(struct hostapd_data *hapd, const u8 *mac,
738                             int accepted, u32 session_timeout)
739 {
740         if (hapd->driver == NULL || hapd->driver->set_radius_acl_auth == NULL)
741                 return 0;
742         return hapd->driver->set_radius_acl_auth(hapd->drv_priv, mac, accepted,
743                                                  session_timeout);
744 }
745
746 static inline int
747 hostapd_set_radius_acl_expire(struct hostapd_data *hapd, const u8 *mac)
748 {
749         if (hapd->driver == NULL ||
750             hapd->driver->set_radius_acl_expire == NULL)
751                 return 0;
752         return hapd->driver->set_radius_acl_expire(hapd->drv_priv, mac);
753 }
754
755 #ifdef CONFIG_IEEE80211N
756 static inline int
757 hostapd_set_ht_params(const char *ifname, struct hostapd_data *hapd,
758                       const u8 *ht_capab, size_t ht_capab_len,
759                       const u8 *ht_oper, size_t ht_oper_len)
760 {
761         if (hapd->driver == NULL || hapd->driver->set_ht_params == NULL ||
762             ht_capab == NULL || ht_oper == NULL)
763                 return 0;
764         return hapd->driver->set_ht_params(
765                 ifname, hapd->drv_priv, ht_capab, ht_capab_len,
766                 ht_oper, ht_oper_len);
767 }
768 #endif /* CONFIG_IEEE80211N */
769
770 static inline int
771 hostapd_drv_none(struct hostapd_data *hapd)
772 {
773         return hapd->driver && os_strcmp(hapd->driver->name, "none") == 0;
774 }
775
776 static inline int
777 hostapd_set_wps_beacon_ie(struct hostapd_data *hapd, const u8 *ie, size_t len)
778 {
779         if (hapd->driver == NULL || hapd->driver->set_wps_beacon_ie == NULL)
780                 return 0;
781         return hapd->driver->set_wps_beacon_ie(hapd->conf->iface,
782                                                hapd->drv_priv, ie, len);
783 }
784
785 static inline int
786 hostapd_set_wps_probe_resp_ie(struct hostapd_data *hapd, const u8 *ie,
787                               size_t len)
788 {
789         if (hapd->driver == NULL ||
790             hapd->driver->set_wps_probe_resp_ie == NULL)
791                 return 0;
792         return hapd->driver->set_wps_probe_resp_ie(hapd->conf->iface,
793                                                    hapd->drv_priv, ie, len);
794 }
795
796 #endif /* DRIVER_H */