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