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