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