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